NameVirtualHost 0.0.0.0:80没有任何虚拟主机。

3
我的服务器之前一直正常运行,但现在出了些问题,我不确定是什么原因。
我收到了下面的错误信息,并且无法访问一些子域名。
apache2: Could not reliably determine the server's fully qualified domain name, using     2001:.....:a669 for ServerName
[Sat Dec 14 21:20:36 2013] [warn] NameVirtualHost 0.0.0.0:80 has no VirtualHosts
...
[Sat Dec 14 21:20:36 2013] [warn] NameVirtualHost 0.0.0.0:80 has no VirtualHosts
Syntax OK

我尝试将ports.conf更改为Listen 80和Listen 0.0.0.0:80(请参见http://www.rackaid.com/resources/how-to-disable-ipv6-in-apache-server/)。

以下是我的一个虚拟主机文件。

NameVirtualHost 0.0.0.0:80
Listen 0.0.0.0:80
<VirtualHost 0.0.0.0:80>
    ServerName www.domain.us
    ServerAlias domain.us
    ServerAdmin email@domain.us

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

    ErrorLog ${APACHE_LOG_DIR}/www.domain.us.error.log

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

    CustomLog ${APACHE_LOG_DIR}/www.domain.us.access.log combined

000-default已正确链接。

Apache 2.2.22

谢谢,


你是否已经在一个虚拟主机文件中配置了所有的虚拟主机? - Tharanga Abeyseela
不,它们是分开的文件。我只是在服务器的主机文件中更改了一些名称,似乎一切都正常工作,但启动时仍然出现错误。 - Aaron
请问是否可以发布其他虚拟主机配置文件的详细信息,仅包括以下部分的虚拟主机声明:NameVirtualHost 0.0.0.0:80 Listen 0.0.0.0:80 <VirtualHost 0.0.0.0:80> - Tharanga Abeyseela
除了目录和服务器名称不同外,其他的都一样。 - Aaron
你确定你还在使用Apache 2.2.22吗?很多用户在升级到Ubuntu 13.10后遇到了这些问题,因为它使用的是Apache2.4。 - Rune
1个回答

10

如果我的猜测是正确的,而且您的系统最近已经更新过,那么您现在正在使用的是Apache 2.4而不是2.2,就像许多其他刚刚转移到新的Ubuntu 13.10版本的用户一样。 (如果您还没有更改为Apache 2.4,则现在可能是更新新的*.conf文件的好时机。)

这里有一个非常好的解释,关于如何使命名虚拟主机在Apache 2.4中工作: http://httpd.apache.org/docs/2.4/vhosts/name-based.html

基本上:

  1. 从现在开始不要使用任何"NameVirtualHost"条目
  2. 所有虚拟主机条目都应该像这样开始<VirtualHost *:80>
  3. 确保每个虚拟主机条目中只包含一个ServerName,例如ServerName www.example.com

最终它应该看起来像这样:

<VirtualHost *:80>
    # This first-listed virtual host is also the default for *:80
    ServerName www.example.com
    ServerAlias example.com 
    DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
    ServerName other.example.com
    DocumentRoot /www/otherdomain
</VirtualHost>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接