Apache web服务器加载/index页面而不是直接加载index.php。

huangapple go评论108阅读模式
英文:

apache webserver loading index of / page instead of directly loading the index.php

问题

我按照这个指南安装和使用了Apache,并修改了配置文件,以便它可以提供我的项目,该项目位于/home/user/Desktop/app/src/。

index.php文件本身位于php/文件夹中。
Apache web服务器加载/index页面而不是直接加载index.php。

以下是我为这个项目创建的配置文件:

/etc/apache2/sites-available/chatapp.conf:

  1. <VirtualHost *:80>
  2. ServerAdmin webmaster@localhost
  3. ServerName chatapp
  4. ServerAlias www.chatapp
  5. DocumentRoot /home/user/Desktop/RT_chatapp/src/
  6. ErrorLog ${APACHE_LOG_DIR}/error.log
  7. CustomLog ${APACHE_LOG_DIR}/access.log combined
  8. </VirtualHost>

/etc/apache2/apache2.conf:

  1. <Directory />
  2. Options Indexes FollowSymLinks Includes ExecCGI
  3. AllowOverride All
  4. Require all granted
  5. </Directory>
  6. <Directory /usr/share>
  7. AllowOverride None
  8. Require all granted
  9. </Directory>
  10. <Directory /var/www/>
  11. Options Indexes FollowSymLinks
  12. AllowOverride None
  13. DirectoryIndex index.php index.html
  14. Require all granted
  15. </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.
Apache web服务器加载/index页面而不是直接加载index.php。

Here are the conf files that I have for this project

/etc/apache2/sites-available/chatapp.conf:

  1. &lt;VirtualHost *:80&gt;
  2. ServerAdmin webmaster@localhost
  3. ServerName chatapp
  4. ServerAlias www.chatapp
  5. DocumentRoot /home/user/Desktop/RT_chatapp/src/
  6. ErrorLog ${APACHE_LOG_DIR}/error.log
  7. CustomLog ${APACHE_LOG_DIR}/access.log combined
  8. &lt;/VirtualHost&gt;

/etc/apache2/apache2.conf:

  1. &lt;Directory /&gt;
  2. Options Indexes FollowSymLinks Includes ExecCGI
  3. AllowOverride All
  4. Require all granted
  5. &lt;/Directory&gt;
  6. &lt;Directory /usr/share&gt;
  7. AllowOverride None
  8. Require all granted
  9. &lt;/Directory&gt;
  10. &lt;Directory /var/www/&gt;
  11. Options Indexes FollowSymLinks
  12. AllowOverride None
  13. DirectoryIndex index.php index.html
  14. Require all granted
  15. &lt;/Directory&gt;

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

huangapple
  • 本文由 发表于 2023年7月10日 22:31:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76654779.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定