1、环境
LAMP
2、问题
linux下直接访问discuz论坛域名,只显示apache欢迎界面,仍需要在域名后面输入index.php,才能正常访问。
3、已尝试但无效的办法
3.1 查看SELinux状态,临时关闭selinux模式 setenforce 0
。无效。
3.2 修改httpd服务Apache网站根目录/var/www/html。无效。
3.3 Filezilla中将/var/www/html
下所有文件权限设为777。无效。
3.4 Linux主机后台vim /etc/httpd/conf/httpd.conf
,找到DirectoryIndex
,把index.html
修改为index.php
,然后重启Apache。无效。
3.5 同3.4,找到DirectoryIndex
,保留index.html
,添加index.php
,并把顺序放在最前面。无效。
3.6 进入discuz论坛后台,尝试进行首页域名、二级域名等设置。无效。
4、最终解决办法
4.1 通过Filezilla连接主机,把 /etc/httpd/conf 目录下的httpd.conf文件下载到本地,然后用Notepad++打开进行编辑。你也可以远程连接Linux主机后,执行 vim /etc/httpd/conf/httpd.conf
,然后按指令进行远程编辑,这个不是最方便的方案,容易误操作,建议在本地编辑后重新上传覆盖。
4.2 找到DirectoryIndex,把代码修改成DirectoryIndex SourceFolder/index.php
,让Apache在SourceFolder中遍历寻找index.php
4.3 在linux主机界面 service httpd restart
4.4 浏览器地址栏直接输入域名,成功访问。不需要再加/index.php
。
5、备注
网上的中文资料都不太靠谱,有问题推荐查StackOverflow。