NameVirtualHost 0.0.0.0:80没有VirtualHosts

时间:2013-12-15 06:38:57

标签: apache ubuntu apache2 config

我的服务器工作正常,但有些事情发生了变化,我不确定是什么。

我收到以下错误,无法获取某些子域名。

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/

这是我的一个vhost文件。

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

谢谢,

1 个答案:

答案 0 :(得分:10)

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

以下是关于如何使基于命名的VirtualHosts在Apache 2.4中运行的非常好的解释: http://httpd.apache.org/docs/2.4/vhosts/name-based.html

本质上:

  1. 从现在起不要使用任何“NameVirtualHost”条目
  2. 启动所有VirtualHost条目,例如<VirtualHost *:80>
  3. 确保在每个VirtualHost条目中只包含一个ServerName,例如。 ServerName www.example.com
  4. 最后它应该是这样的:

    <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>
    
相关问题