2010-10-30 70 views
1

我運行Ubuntu上訪問本地主機時未找到錯誤。我的Apache2默認文件看起來是這樣的:404試圖本地LAMP服務器

<VirtualHost *:80> 
     ServerAdmin [email protected] 

     DocumentRoot /var/www/ 
     <Directory /> 
       Options FollowSymLinks 
       AllowOverride None 
     </Directory> 
     <Directory /var/www/> 
       Options Indexes FollowSymLinks MultiViews 
       AllowOverride None 
       Order allow,deny 
       allow from all 
     </Directory> 

     ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
     <Directory "/usr/lib/cgi-bin"> 
       AllowOverride None 
       Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
       Order allow,deny 
       Allow from all 
     </Directory> 

     ErrorLog ${APACHE_LOG_DIR}/error.log 

     # Possible values include: debug, info, notice, warn, error, crit, 
     # alert, emerg. 
     LogLevel warn 

     CustomLog ${APACHE_LOG_DIR}/access.log combined 

    Alias /doc/ "/usr/share/doc/" 
    <Directory "/usr/share/doc/"> 
     Options Indexes MultiViews FollowSymLinks 
     AllowOverride None 
     Order deny,allow 
     Deny from all 
     Allow from 127.0.0.0/255.0.0.0 ::1/128 
    </Directory> 

</VirtualHost> 

我/這個文件在/ var/WWW名爲index.php的

<? 
phpinfo(); 
?> 

當我在我的瀏覽器訪問http://localhost/,我得到了404未找到錯誤:

請求的URL /沒有被此服務器上找到。 的Apache/2.2.16(Ubuntu的)在本地主機端口80

服務器什麼是我做錯了什麼?當我第一次設置LAMP時,這實際上工作,但它現在不工作。

+0

@Codemwnci沒有進攻,但他怎麼能從Apache的錯誤信息,如果它沒有運行? – hatkirby 2010-10-30 18:18:44

+1

您確定沒有2個apaches同時運行嗎?它可能會導致類似的問題。 – 2010-10-30 18:20:18

+0

我從來沒有做過任何表明兩個Apaches同時運行的東西。就像我說的那樣,當我第一次設置它時,這起作用,然後發生了什麼事情,我將DocumentRoot更改爲另一個位置並將其更改回來,然後它開始不起作用。 – slandau 2010-10-30 18:25:09

回答

5

在/ etc看一看的Apache2 /。看來我的升級到10.10已經從該目錄中刪除了符號鏈接。嘗試符號鏈接默認到/ etc/apache2的/網站可用/默認

sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/default 
+0

試過了,仍然一無所獲... – slandau 2010-10-30 19:17:35

+0

你重新啓動Apache的呢? – 2010-10-30 19:19:08

+0

好的,在我重新啓動Apache2後,我進入'Index of /'頁面,在那裏我可以看到目錄。如何讓它再次默認使用該目錄中的Index.php頁面? – slandau 2010-10-30 19:26:03

0

你已經安裝了PHP模塊,並啓用?因爲,通常情況下,它會在服務器簽名中提及,但你的不會。這也可以解釋爲什麼服務器無法識別index.php是您的意思/。 /啓用站點

嘗試

sudo a2enmod php5 
+0

模塊PHP5已經啓用 – slandau 2010-10-30 18:23:53

0

完全相同的問題與我。

繼爲我工作:

由於安德烈亞斯楊松提到,符號鏈接默認爲:

sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/default 

並重新啓動的Apache2:

sudo /etc/init.d/apache2 restart 

,然後它的工作原理:

http://localhost/ 
1

檢出錯誤日誌(tail /var/log/apache2/error.log)以查找Apache嘗試查找的確切路徑。

0

使用URL本地主機/ info.php的。 文件info.php必須包含 <?php phpinfo(); ?>