2016-01-15 64 views
0

我刚刚部署了LAMP来准备Elgg安装。在我部署了apache和php之后,我想通过创建info.php文件来测试我的进度。我把文件在/ var/WWW /并试图从浏览器访问它只能得到一个错误:为什么info.php只有放在/ var/www/html而不是/ 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安装设置。任何人都可以向我解释为什么?为教育目的。

+8

,因为默认情况下'/ var/www/html'是默认文档根目录。如果您只想使用/ var/www/ –

+0

,则必须在httpd.conf中更改您的配置文件夹的根目录位置为“DocumentRoot”。在我的服务器上,它位于'/ etc/httpd/conf /'中的'httpd.conf'中。 – chris85

回答

1

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

例如,如果DocumentRoot的被设置为/var/www/html那么将导致/var/www/html/folder1/yourpage.php被提供给发出请求的客户端

在Ubuntu默认位置在该文件中http://www.yoursite.com/folder1/yourpage.php的请求/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) 
+0

我在这个位置找不到http.config? – haytham

+0

它的httpd.conf和http://wiki.apache.org/httpd/DistrosDefaultLayout – PoX

+0

实际上这个文件在Ubuntu中不存在http://wiki.apache.org/httpd/DistrosDefaultLayout#Debian.2C_Ubuntu_.28Apache_httpd_2.x。 29: – haytham

1

因为/var/www/html是你的Apache的默认文档根路径。 您可以编辑/etc/apache2/sites-available/default.conf中的路径。找到的DocumentRoot例如Apache的

/var/www/html 

enter image description here

+0

我无法在任何位置找到http.config? – haytham

0

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

相关问题