apache 错误:“VirtualHost *:80 -- 不支持将 * 端口和非 * 端口与 NameVirtualHost 地址混合,处理未定义的结果”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:42:32  来源:igfitidea点击:

Error: "VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results"

windowsapachewamp

提问by Glenn Slaven

I'm running WAMP v2.0 on WindowsXP and I've got a bunch of virtual hosts setup in the http-vhosts.conf file.

我在 WindowsXP 上运行 WAMP v2.0,我在 http-vhosts.conf 文件中设置了一堆虚拟主机。

This was working, but in the last week whenever I try & start WAMP I get this error in the event logs:

这是有效的,但在上周,每当我尝试启动 WAMP 时,我都会在事件日志中收到此错误:

VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results.

VirtualHost *:80 -- 不支持将 * 端口和非 * 端口与 NameVirtualHost 地址混合,处理未定义的结果。

and the server won't start. I can't think of what's changed.

并且服务器不会启动。我想不出有什么变化。

I've copied the conf file below.

我已经复制了下面的 conf 文件。

NameVirtualHost *
<VirtualHost *:80>
    ServerName dev.blog.slaven.net.au
    ServerAlias dev.blog.slaven.net.au
    ServerAdmin [email protected]
    DocumentRoot "c:/Project Data/OtherProjects/slaven.net.au/blog/" 
    ErrorLog "logs/blog.slaven.localhost-error.log"
    CustomLog "logs/blog.slaven.localhost-access.log" common

    <Directory "c:/Project Data/OtherProjects/slaven.net.au/blog/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
            Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

EDIT:I meant to add, if I change the NameVirtualHosts directive to specify a port, i.e

编辑:我想添加,如果我更改 NameVirtualHosts 指令以指定端口,即

NameVirtualHost *:80

I get this error:

我收到此错误:

Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:80

通常每个套接字地址(协议/网络地址/端口)只允许使用一次。:make_sock:无法绑定到地址 0.0.0.0:80

回答by nohj

NameVirtualHost *:80

I get this error:

Only one usage of each socket address (protocol/network address/port) is normally >permitted. : make_sock: could not bind to address 0.0.0.0:80

名称虚拟主机 *:80

我收到此错误:

通常,每个套接字地址(协议/网络地址/端口)只允许使用一次。:make_sock:无法绑定到地址 0.0.0.0:80

I think this might be because you have somthing else listening to port 80. Do you have any other servers (or for example Skype) running?

我认为这可能是因为您有其他东西在监听端口 80。您是否有其他服务器(或例如 Skype)在运行?

(If it was Skype: untick "Tools > Options > Advanced > Connection > Use port 80 and 443 as alternatives for incoming connections")

(如果是 Skype:取消勾选“工具 > 选项 > 高级 > 连接 > 使用端口 80 和 443 作为传入连接的替代选项”)

回答by dguaraglia

Well, it seems the problem there is the way (and order) in which you assign the ports.

好吧,问题似乎在于您分配端口的方式(和顺序)。

Basically, *:80 means "use port 80 for all hosts in this configuration". When you do this, Apache tries to bind that host to 0.0.0.0:80, which means that host will receive every single packet coming to the machine through port 80, regardless of what virtual host it was intended to go to. That's something you should use only once, and only if you have onehost in that configuration.

基本上,*:80 表示“在此配置中为所有主机使用端口 80”。当您这样做时,Apache 会尝试将该主机绑定到 0.0.0.0:80,这意味着该主机将接收通过端口 80 到达机器的每个数据包,而不管它打算去哪个虚拟主机。这是您应该只使用一次的东西,并且仅当您在该配置中有一台主机时。

Thus, if you have the same *:80 directive on two hosts in the configuration file, the server won't load because it will try to bind 0.0.0.0:80 twice, failing on the second try. (which explains the "Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:80" message).

因此,如果您在配置文件中的两台主机上有相同的 *:80 指令,服务器将不会加载,因为它会尝试绑定 0.0.0.0:80 两次,第二次尝试失败。(这解释了“通常允许每个套接字地址(协议/网络地址/端口)仅使用一次。:make_sock:无法绑定到地址 0.0.0.0:80”消息)。