英文:
apache webserver loading index of / page instead of directly loading the index.php
问题
我按照这个指南安装和使用了Apache,并修改了配置文件,以便它可以提供我的项目,该项目位于/home/user/Desktop/app/src/。
以下是我为这个项目创建的配置文件:
/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>
/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>
我正在运行PHP 8.2.5和Apache 2.4.41
PS:值得一提的是,我对使用Apache等Web服务器相对新手。
我尝试将 "index.php" 添加到DirectoryIndex中,并修改文档根目录为/home/user/Desktop/RT_chatapp/src/php/,但没有成功。
英文:
I followed this guide on installing and using apache, and changed the conf files so that it would serve my project which is located in /home/user/Desktop/app/src/.
The index.php itself is in the php/ folder.
Here are the conf files that I have for this project
/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>
/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>
I am running php 8.2.5 and apache 2.4.41
ps I thought it might be worth mentioning that I am pretty new to web servers using apache and such
I tried adding "index.php" to the directoryIndex as well as modifying the document root to /home/user/Desktop/RT_chatapp/src/php/ instead but that didn't work.
答案1
得分: -1
如@timchessish所说,一个非常简单的修复方法就是将index.php直接移动到配置文件中设置的DocumentRoot下的src/目录中。
英文:
as @timchessish said, a very simple fix was to just move the index.php directly under src/ where the DocumentRoot was set to in the config file
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论