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


24

这是启动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

我首先按照此指南设置了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>

用X域名来保护无辜的人:-)

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

NameVirtualHost *

奇怪的是,这三个站点中的两个似乎一切正常。


发布您的完整(!)Apache httpd配置或至少每个NameVirtualHost和<VirtualHost ...>行。
joschi

您不能在同一ip:port上混合使用两种类型。我有一个设置,其中有两个IP,一个挂有massvhost,另一个挂有所有常规的基于名称的主机。更重要的是,目标是什么?您想达到什么目的?你有什么限制?
Marcin

Answers:


29

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

例:

NameVirtualHost *:80
NameVirtualHost *:81

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

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

# This will not work!
<VirtualHost *>
# ...
</VirtualHost>

有关详细信息,请阅读Apache Virtual Host文档


希望我能投票一次以上。他们确实应该在文档中更清楚地指出这一点。
亚历克斯W


5

除了响应之外,我注意到的一件事是,您必须在每个NameVirtualHost和VirtualHost指令上未明确声明:80的情况下才能运行SSL,apache将不支持具有:

名称VirtualHost *

名称VirtualHost *:443

在同一配置中混合使用,如果这样做,则会在apache监听端口0时出现错误。

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


0

例如:

<VirtualHost 85.25.97.252:80>
ServerName domain.com
ServerAlias * .domain.com
ServerAdmin webmaster@domain.com
DocumentRoot“ /var/www/domain.com/httpdocs/”
<目录“ /var/www/domain.com/ httpdocs /“>
选项索引FollowSymLinks
AllowOverride All
Order允许,拒绝
所有
</ Directory>
</ VirtualHost>

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.