[英]why is it that info.php only work if placed in /var/www/html not /var/www/?
I have just deployed LAMP in preparation for Elgg installation. 我刚刚部署了LAMP,以准备安装Elgg。 After I deployed apache and php I wanted to test my progress by creating info.php file.
部署apache和php后,我想通过创建info.php文件来测试进度。 I placed the file in /var/www/ and tried to visit it from the browser only to get an error:
我将文件放在/ 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
when I placed the same exact file in /var/www/html it worked and displayed the Apache and php installation settings. 当我在/ var / www / html中放置相同的文件时,它可以工作并显示Apache和php的安装设置。 Can anyone please explain to me why?
谁能向我解释为什么? for educational purposes.
用于教育目的。
Apache webserver will show documents that are put to a specific location. Apache Web服务器将显示放置在特定位置的文档。 Root of that location is referred as document root.
该位置的根称为文档根。
For example, if DocumentRoot were set to /var/www/html
then a request for http://www.yoursite.com/folder1/yourpage.php
would result in the file /var/www/html/folder1/yourpage.php
being served to the requesting client 例如,如果DocumentRoot设置为
/var/www/html
则对http://www.yoursite.com/folder1/yourpage.php
的请求将导致文件/var/www/html/folder1/yourpage.php
提供给请求客户
In ubuntu default location is /var/www
for server root and on Centos its /var/www/html
在ubuntu中,服务器根目录的默认位置是
/var/www
,而在Centos上,默认位置是/var/www/html
This change requires a service restart. 此更改需要重新启动服务。
you can change this from /etc/httpd.conf
where there is a section about document root. 您可以从
/etc/httpd.conf
中的有关文档根目录的部分进行更改。
But again on your distro which is ubuntu its under /etc/apache2/http.conf
但是再次在您的发行版上是ubuntu,它在
/etc/apache2/http.conf
Debian based systems 基于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)
Default DocumentRoot of apache is /var/www/html. apache的默认DocumentRoot是/ var / www / html。 Edit your httpd.conf config file located in
/etc/apache2
directory and change DocumentRoot to /var/www 编辑位于
/etc/apache2
目录中的httpd.conf配置文件,并将DocumentRoot更改为/ var / www
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.