为什么info.php只有放在/var/www/html而不是/var/www/中才能工作?

为什么info.php只有放在/var/www/html而不是/var/www/中才能工作?,php,apache,Php,Apache,我刚刚部署了LAMP,准备安装Elgg。在部署apache和php之后,我想通过创建info.php文件来测试我的进度。我将该文件放在/var/www/中,并试图从浏览器中访问它,但结果出现错误: Not Found The requested URL /info.php was not found on this server. Apache/2.4.7 (Ubuntu) Server at 192.168.0.9 Port 80 当我将相同的文件放入/var/www/html时,它工作

我刚刚部署了LAMP,准备安装Elgg。在部署apache和php之后,我想通过创建info.php文件来测试我的进度。我将该文件放在/var/www/中,并试图从浏览器中访问它,但结果出现错误:

Not Found

The requested URL /info.php was not found on this server.

Apache/2.4.7 (Ubuntu) Server at 192.168.0.9 Port 80

当我将相同的文件放入/var/www/html时,它工作并显示Apache和php安装设置。谁能给我解释一下原因吗?出于教育目的。

Apache Web服务器将显示放置到特定位置的文档。该位置的根称为文档根

例如,如果DocumentRoot设置为
/var/www/html
,则请求
http://www.yoursite.com/folder1/yourpage.php
将导致向请求客户端提供文件
/var/www/html/folder1/yourpage.php

在ubuntu中,服务器根目录的默认位置是
/var/www
,而在Centos上,默认位置是
/var/www/html

此更改需要重新启动服务

您可以从
/etc/httpd.conf
中更改,其中有一个关于文档根的部分

但同样在您的发行版ubuntu上,它位于
/etc/apache2/http.conf

基于Debian的系统

ServerRoot              ::      /etc/apache2
DocumentRoot            ::      /var/www
Apache Config Files     ::      /etc/apache2/apache2.conf
                        ::      /etc/apache2/ports.conf
Default VHost Config    ::      /etc/apache2/sites-available/default,/etc/apache2/sites-enabled/000-default
Module Locations        ::      /etc/apache2/mods-available, /etc/apache2/mods-enabled
ErrorLog                ::      /var/log/apache2/error.log
AccessLog               ::      /var/log/apache2/access.log
cgi-bin                 ::      /usr/lib/cgi-bin
binaries (apachectl)    ::      /usr/sbin
start/stop              ::      /etc/init.d/apache2 (start|stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean)

ApacheWebServer将显示放在特定位置的文档。该位置的根称为文档根

例如,如果DocumentRoot设置为
/var/www/html
,则请求
http://www.yoursite.com/folder1/yourpage.php
将导致向请求客户端提供文件
/var/www/html/folder1/yourpage.php

在ubuntu中,服务器根目录的默认位置是
/var/www
,而在Centos上,默认位置是
/var/www/html

此更改需要重新启动服务

您可以从
/etc/httpd.conf
中更改,其中有一个关于文档根的部分

但同样在您的发行版ubuntu上,它位于
/etc/apache2/http.conf

基于Debian的系统

ServerRoot              ::      /etc/apache2
DocumentRoot            ::      /var/www
Apache Config Files     ::      /etc/apache2/apache2.conf
                        ::      /etc/apache2/ports.conf
Default VHost Config    ::      /etc/apache2/sites-available/default,/etc/apache2/sites-enabled/000-default
Module Locations        ::      /etc/apache2/mods-available, /etc/apache2/mods-enabled
ErrorLog                ::      /var/log/apache2/error.log
AccessLog               ::      /var/log/apache2/access.log
cgi-bin                 ::      /usr/lib/cgi-bin
binaries (apachectl)    ::      /usr/sbin
start/stop              ::      /etc/init.d/apache2 (start|stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean)

因为
/var/www/html
是apache的默认文档根路径。 您可以在
/etc/apache2/sites available/default.conf
中编辑路径。查找DocumentRoot作为

/var/www/html

因为
/var/www/html
是apache的默认文档根路径。 您可以在
/etc/apache2/sites available/default.conf
中编辑路径。查找DocumentRoot作为

/var/www/html

apache的默认文档根是/var/www/html。编辑位于
/etc/apache2
目录中的httpd.conf配置文件,并将DocumentRoot更改为/var/www

apache的默认DocumentRoot为/var/www/html。编辑位于
/etc/apache2
目录中的httpd.conf配置文件,并将DocumentRoot更改为/var/www

,因为默认情况下
/var/www/html
是默认的文档根目录。如果只想使用/var/www/conf,则必须在httpd.conf中进行更改。您的配置文件夹的根位置为
DocumentRoot
。在
/etc/httpd/conf/
中的
httpd.conf
中的我的服务器上,因为默认情况下
/var/www/html
是默认的文档根目录。如果只想使用/var/www/conf,则必须在httpd.conf中进行更改。您的配置文件夹的根位置为
DocumentRoot
。在我的服务器上,它位于
httpd.conf
/etc/httpd/conf/
中。我在这两个位置都找不到http.config?我在这两个位置都找不到http.config?实际上,这个文件在Ubuntu中不存在:这是一个参考链接,供您查看。我也在回答这个问题。我找到了它,为了修改文档根目录,我需要在/etc/apache2/apache2.confI中进行更改。在这个位置找不到http.config?实际上这个文件在Ubuntu中不存在:这是一个供您查看的参考链接。我也在回答这个问题,我找到了它,为了修改文档根目录,我需要在/etc/apache2/apache2.conf中进行更改