如何解决apache2 httpd错误“不支持将*端口和非*端口与NameVirtualHost地址混合使用”

rca*_*ell 24 virtualhost apache-2.2

这是我在启动 Apache2 时遇到的错误:

 * Starting web server apache2
 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
 [Wed Oct 21 16:37:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
 [Wed Oct 21 16:37:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
 [Wed Oct 21 16:37:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
 [Wed Oct 21 16:37:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
 [Wed Oct 21 16:37:26 2009] [warn] NameVirtualHost *:80 has no VirtualHosts
Run Code Online (Sandbox Code Playgroud)

我首先按照本指南设置 Apache 以托管多个站点:

http://www.debian-administration.org/articles/412

然后我在 ServerFault 上发现了一个类似的问题并尝试应用该解决方案,但没有帮助。

这是我的最终 VirtualHost 配置的示例:

<VirtualHost *:80>
    ServerAdmin admin@xxx.com
    ServerName  www.xxx.com
    ServerAlias xxx.com

    # Indexes + Directory Root.
    DirectoryIndex index.html
    DocumentRoot /var/www/www.xxx.com

    # Logfiles
    ErrorLog  /var/www/www.xxx.com/logs/error.log
    CustomLog /var/www/www.xxx.com/logs/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

使用域 X 来保护无辜者:-)

此外,我在指南中提到的conf.d/virtual.conf文件如下所示:

NameVirtualHost *
Run Code Online (Sandbox Code Playgroud)

奇怪的是,对于三个站点中的两个,一切似乎都运行良好。

jos*_*chi 29

命名为的 IP 地址NameVirtualHost必须与每个VirtualHost元素中的 IP 地址匹配。

例子:

NameVirtualHost *:80
NameVirtualHost *:81

<VirtualHost *:80>
# ...
</VirtualHost>

<VirtualHost *:81>
# ...
</VirtualHost>

# This will not work!
<VirtualHost *>
# ...
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请阅读Apache 虚拟主机文档


Eri*_*nis 13

替换这个:

NameVirtualHost *
Run Code Online (Sandbox Code Playgroud)

有了这个:

NameVirtualHost *:80
Run Code Online (Sandbox Code Playgroud)

  • 我很欣赏这个简单的答案,并希望我能同时接受 (2认同)

Rod*_*igo 5

添加到响应中,我注意到的一件事是,如果没有在每个 NameVirtualHost 和 VirtualHost 指令上显式声明 :80 就无法运行 SSL,apache 将不支持:

名称虚拟主机 *

名称虚拟主机 *:443

混合在相同的配置中,如果这样做,您将在 apache 侦听端口 0 时出错。

对我来说,我只是在每个主机上添加了 :80,这样 SSL 就可以正常工作。