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

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

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:

<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.
Apache web服务器加载/index页面而不是直接加载index.php。

Here are the conf files that I have for this project

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

&lt;VirtualHost *:80&gt;
    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
&lt;/VirtualHost&gt;

/etc/apache2/apache2.conf:

&lt;Directory /&gt;
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
&lt;/Directory&gt;

&lt;Directory /usr/share&gt;
        AllowOverride None
        Require all granted
&lt;/Directory&gt;

&lt;Directory /var/www/&gt;
        Options Indexes FollowSymLinks
        AllowOverride None
        DirectoryIndex index.php index.html
        Require all granted
&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:

确定