[英]404 Not Found Error when trying to access localhost on local LAMP server
我正在運行Ubuntu。 我的Apache2默認文件如下所示:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
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 Not Found錯誤:
在此服務器上找不到請求的URL /。 位於localhost端口80的Apache / 2.2.16(Ubuntu)服務器
我究竟做錯了什么? 當我第一次設置LAMP時,這實際上有效但現在不能正常工作。
看看/ etc / apache2 / sites-enabled。 看起來我升級到10.10已經擦除了該目錄中的符號鏈接。 嘗試將符號鏈接默認為/ etc / apache2 / sites-available / default
sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/default
檢查錯誤日志(tail /var/log/apache2/error.log)以找出Apache嘗試查找的確切路徑。
我的問題完全一樣。
以下為我工作:
正如Andreas Jansson所提到的,symlink默認為:
sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/default
並重新啟動apache2:
sudo /etc/init.d/apache2 restart
然后它的工作原理:
http://localhost/
使用url localhost / info.php。 文件info.php必須包含<?php phpinfo(); ?>
<?php phpinfo(); ?>
你是否安裝並啟用了PHP模塊? 因為,通常情況下,它會在服務器簽名中提及,但是您的服務器簽名不會。 這也可以解釋為什么服務器無法識別index.php
是/
你的意思。
嘗試
sudo a2enmod php5
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.