[英]404 Not Found Error when trying to access localhost on local LAMP server
I'm running Ubuntu. 我正在运行Ubuntu。 My Apache2 default file looks like this: 我的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>
I have this file called Index.php in /var/www/ 我在/ var / www /中有一个名为Index.php的文件
<?
phpinfo();
?>
When I access http://localhost/ in my browser, I'm getting the 404 Not Found error: 当我在浏览器中访问http:// localhost /时,我收到404 Not Found错误:
The requested URL / was not found on this server. 在此服务器上找不到请求的URL /。 Apache/2.2.16 (Ubuntu) Server at localhost Port 80 位于localhost端口80的Apache / 2.2.16(Ubuntu)服务器
What am I doing wrong? 我究竟做错了什么? This actually worked when I first setup LAMP but it's not working now. 当我第一次设置LAMP时,这实际上有效但现在不能正常工作。
Have a look in /etc/apache2/sites-enabled. 看看/ etc / apache2 / sites-enabled。 It seems like my upgrade to 10.10 has wiped the symlinks from that directory. 看起来我升级到10.10已经擦除了该目录中的符号链接。 Try symlinking default to /etc/apache2/sites-available/default 尝试将符号链接默认为/ 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尝试查找的确切路径。
Exactly the same problem with me. 我的问题完全一样。
Following worked for me : 以下为我工作:
As Andreas Jansson mentioned, symlink default to: 正如Andreas Jansson所提到的,symlink默认为:
sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/default
and restarted apache2: 并重新启动apache2:
sudo /etc/init.d/apache2 restart
and then it works: 然后它的工作原理:
http://localhost/
Use the url localhost/info.php. 使用url localhost / info.php。 File info.php must contain <?php phpinfo(); ?>
文件info.php必须包含<?php phpinfo(); ?>
<?php phpinfo(); ?>
Do you have the PHP module installed and enabled? 你是否安装并启用了PHP模块? Because, normally, it would mention that in the server signature, but yours doesn't. 因为,通常情况下,它会在服务器签名中提及,但是您的服务器签名不会。 That would also explain why the server doesn't recognize that index.php
is what you mean by /
. 这也可以解释为什么服务器无法识别index.php
是/
你的意思。
Try 尝试
sudo a2enmod php5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.