【发布时间】:2014-03-16 21:04:55
【问题描述】:
这几天我睡在我的http://localhost 上工作,阅读/var/www 的页面...
我在 Apache2 日志中发现“AH00094”错误,并且(Apache2 创建?)一个惊讶的/var/www/html,Apache2 尝试使用。
现在我的http://localhost/anything 不起作用(浏览器出现错误 404)。
如何解决?我需要找回我的 http://localhost 处理 /var/www 的文件!
上下文
我正在使用带有 Apache2 的 Ubuntu12,所有默认和标准。
我检查了tail /var/log/apache2/error.log 的错误日志,以找出 Apache 显示的确切路径
... [core:notice] [pid 1597] AH00094: Command line: '/usr/sbin/apache2'
... [:error] [pid 1604] [client 127.0.0.1:40624] script '/var/www/html/info.php' not found or unable to stat
文件夹/var/www/html 是新的,所有,如'/var/www/info.php',都在/var/www,而不是/var/www/html。
sudo nano /etc/apache2/apache2.conf
在最后一行添加
ServerName localhost
(现在没有关于 localhost 的日志错误,但没有任何作用)
PS:我检查了其他相关问题,但不是同一个问题:Permissions for /var/www/html,Attempting to use symbolic link for var/www/html
我害怕使用 clues of this answer ... 在我的 Ubuntu 中没有 .conf 指示的文件。我必须创建它吗?安全吗?
正如@RahilWazir 所建议的,这也是我的“/etc/apache2/sites-available/000-default.conf”,
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
【问题讨论】:
-
粘贴
/etc/apache2/sites-available/default文件的内容。 -
感谢@RahilWazir!好吧,只有这两个文件,
000-default.confdefault-ssl.conf,我可以用000-default.conf吗? -
是的,请显示内容。
-
Ops,我编辑了问题,现在你可以看到我的 000-default.conf
-
在那里你可以看到它
DocumentRoot /var/www/html?将其更改为DocumentRoot /var/www