本文介绍了我需要“/var/www"但是 Apache2 尝试使用空的“/var/www/html"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这几天我睡在我的 http://localhost 工作,并从 /var/www 阅读页面...

This days I sleep with my http://localhost working, and reading pages from /var/www...

我醒来时听到AH00094"Apache2 日志中的错误,以及(Apache2 已创建?)一个令人惊讶的 /var/www/html,Apache2 尝试使用.

I woke up with an "AH00094" error at Apache2 log, and (Apache2 created?) a surprised /var/www/html, that Apache2 try to use.

现在我的 http://localhost/anything 不起作用(浏览器出现错误 404).

Now my http://localhost/anything not works (error 404 at browser).

如何解决?我需要恢复我的 http://localhost 处理 /var/www 中的文件!

How to fix it? I need back my http://localhost working with files at /var/www!

我使用 Ubuntu12 和 Apache2,所有默认和标准.

I am using Ubuntu12 with Apache2, all default and standard.

我通过 tail/var/log/apache2/error.log 查看了错误日志,以找出 Apache 显示的确切路径

I checked out error log by tail /var/log/apache2/error.log in order to find out exact path that Apache, that shows

 ... [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.

The folder /var/www/html is new, all, like '/var/www/info.php', are at /var/www, not at /var/www/html.

修复了AH00094"错误编辑

 sudo nano /etc/apache2/apache2.conf

并在最后一行添加

 ServerName localhost

(现在没有关于 localhost 的日志错误,但没有任何效果)

(now no log errors about localhost, but nothing works)

PS:我检查了其他相关问题,但不是同一个问题:/var/www/html 的权限, 尝试对 var/www/html 使用符号链接

PS: I checked other related issues, but not is the same problem: Permissions for /var/www/html , Attempting to use symbolic link for var/www/html

我害怕使用 这个答案的线索 ...在我的 Ubuntu 中没有 .conf 指示的文件.我必须创建它?安全吗?

I'm afraid to use the clues of this answer ... in my Ubuntu there are no the .conf indicated files. I must create it? Is secure?

正如@RahilWazir 所建议的,这里也是我的/etc/apache2/sites-available/000-default.conf",

As @RahilWazir suggested, here is also my "/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

推荐答案

请看这里:

为什么有 apache2 www目录已移至/var/www/html?

Debian 中 htdocs 的默认目录显然(我们也很惊讶)从 /var/www 移动到 /var/www/html,而 Ubuntu 复制了这个更改.给出的原因有些合理,但升级路径可能有趣"(如中国谚语)......正如您所遇到的.

The default directory apparently (we were also surprised) moved from /var/www to /var/www/html for htdocs in Debian, and Ubuntu copied this change. The reasons given are somewhat sound, but the upgrade path is probably "interesting" (as in the Chinese proverb)… as you have encountered.

这篇关于我需要“/var/www"但是 Apache2 尝试使用空的“/var/www/html"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 01:40
查看更多