Apache Web服务器加载/目录索引页而非直接加载index.php的问题求助
Apache Web服务器加载/目录索引页而非直接加载index.php的问题求助
大家好,我是个Apache这类Web服务器的新手,最近跟着指南安装并配置Apache来部署我的项目,但遇到了个头疼的问题:服务器总是加载目录索引页,而不是直接加载我的index.php文件,想请各位帮忙看看哪里配置出错了。
先说说我的环境和项目情况:
- PHP版本:8.2.5
- Apache版本:2.4.41
- 项目根目录:
/home/user/Desktop/RT_chatapp/src/ index.php的具体位置:/home/user/Desktop/RT_chatapp/src/php/
下面是我当前的配置文件内容:
虚拟主机配置文件 /etc/apache2/sites-available/chatapp.conf:
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName chatapp ServerAlias www.chatapp DocumentRoot /home/user/Desktop/RT_chatapp/src/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Apache主配置文件 /etc/apache2/apache2.conf 中相关目录配置:
<Directory /> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted </Directory> <Directory /usr/share> AllowOverride None Require all granted </Directory> <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None DirectoryIndex index.php index.html Require all granted </Directory>
我已经尝试过两种解决方法,但都没起作用:
- 在
DirectoryIndex里明确添加了index.php - 把
DocumentRoot修改为/home/user/Desktop/RT_chatapp/src/php/(也就是index.php所在的目录)
实在摸不清哪里出问题了,希望有经验的朋友能帮我排查一下,谢谢大家!
备注:内容来源于stack exchange,提问作者Hemzyy
相关产品推荐
相关产品推荐

