NameVirtualHost *:80 没有 VirtualHosts
我有两个域名、两个 ssl 证书和两个 IP 地址。我正在尝试为它们配置我的 apache 虚拟主机文件。
首先,我注释掉了端口 80 和 443 的“NameVirtualHost”和“Listen”的所有实例。然后我对虚拟主机文件执行了以下操作。
域 1 的虚拟主机文件:
NameVirtualHost 1.1.1.1:80
Listen 1.1.1.1:80
Listen 1.1.1.1:443
<VirtualHost 1.1.1.1:80>
ServerName domain1.com
...
</VirtualHost>
<VirtualHost 1.1.1.1:443>
...
</VirtualHost>
域 2 的虚拟主机文件:
NameVirtualHost 2.2.2.2:80
Listen 2.2.2.2:80
Listen 2.2.2.2:443
<VirtualHost 2.2.2.2:80>
ServerName domain2.com
...
</VirtualHost>
<VirtualHost 2.2.2.2:443>
...
</VirtualHost>
I have two domain names, two ssl certs and two ip addresses. I am trying to configure my apache virtualhost files for them.
First, i commented out all instances of "NameVirtualHost" and "Listen" for ports 80 and 443. Then i did the following with my virtual hosts files.
VirtualHost file for domain1:
NameVirtualHost 1.1.1.1:80
Listen 1.1.1.1:80
Listen 1.1.1.1:443
<VirtualHost 1.1.1.1:80>
ServerName domain1.com
...
</VirtualHost>
<VirtualHost 1.1.1.1:443>
...
</VirtualHost>
VirtualHost file for domain2:
NameVirtualHost 2.2.2.2:80
Listen 2.2.2.2:80
Listen 2.2.2.2:443
<VirtualHost 2.2.2.2:80>
ServerName domain2.com
...
</VirtualHost>
<VirtualHost 2.2.2.2:443>
...
</VirtualHost>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在使用 Ubuntu 服务器的两个月里一直忽略了同样的错误。我发现这篇文章很好地解决了这个错误。谢谢你迈克尔!
就像你Jay一样,我在 /etc/apache2/ports.conf 找到了罪魁祸首。我简单地尝试了这个:
I only commented out that line and no other changes and no more
“NameVirtualHost *:80 没有 VirtualHosts”
I had ignored the same error for the 2 months I have had an Ubuntu server. I found this post nicely solved the error. Thank you Michael!.
As did you Jay, I found the culprit at /etc/apache2/ports.conf . I tried simply this:
I only commented out that line and no other changes and no more
"NameVirtualHost *:80 has no VirtualHosts"
在你的配置中的某个地方,可能是在 Apache 默认配置文件中(我认为 Ubuntu 中的
/etc/apache2/httpd.conf
?有人可以在评论中纠正我),有一行看起来像:将它们删除,并在
VirtualHost
配置文件中添加:在许多默认 Apache 配置中,
Listen
和NameVirtualHost
指令带有通配符,或者全局适用于所有网络接口。由于您使用绑定到不同配置的多个 IP 地址,因此您的配置指令需要比发行版的默认配置文件更具体。Somewhere in your configuration, probably in the Apache default configuration file (I think
/etc/apache2/httpd.conf
in Ubuntu? someone can correct me in the comments), is a line that looks like:Comment them out, and in your
VirtualHost
configuration files, add:In many default Apache configurations, the
Listen
andNameVirtualHost
directives are supplied with wildcards, or globally to apply to all network interfaces. Since you're using multiple IP addresses bound to different configurations, you need to be more specific in your config directives than your distribution's default config file.