2016-01-15 81 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

相關問題