NameVirtualHost *:80 没有 VirtualHosts

发布于 2024-12-01 04:33:05 字数 658 浏览 2 评论 0原文

我有两个域名、两个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长伴 2024-12-08 04:33:05

我在使用 Ubuntu 服务器的两个月里一直忽略了同样的错误。我发现这篇文章很好地解决了这个错误。谢谢你迈克尔
就像你Jay一样,我在 /etc/apache2/ports.conf 找到了罪魁祸首。我简单地尝试了这个:

# NameVirtualHost *:80

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:

# NameVirtualHost *:80

I only commented out that line and no other changes and no more

"NameVirtualHost *:80 has no VirtualHosts"

摇划花蜜的午后 2024-12-08 04:33:05

在你的配置中的某个地方,可能是在 Apache 默认配置文件中(我认为 Ubuntu 中的 /etc/apache2/httpd.conf?有人可以在评论中纠正我),有一行看起来像

NameVirtualHost *:80

# Also
Listen 80
Listen 443

:将它们删除,并在 VirtualHost 配置文件中添加:

Listen 111.111.111.111:80
Listen 222.222.222.222:80
# If also using SSL
Listen 111.111.111.111:443
Listen 222.222.222.222:443

NameVirtualHost 111.111.111.111:80
NameVirtualHost 222.222.222.222:80

在许多默认 Apache 配置中,ListenNameVirtualHost 指令带有通配符,或者全局适用于所有网络接口。由于您使用绑定到不同配置的多个 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:

NameVirtualHost *:80

# Also
Listen 80
Listen 443

Comment them out, and in your VirtualHost configuration files, add:

Listen 111.111.111.111:80
Listen 222.222.222.222:80
# If also using SSL
Listen 111.111.111.111:443
Listen 222.222.222.222:443

NameVirtualHost 111.111.111.111:80
NameVirtualHost 222.222.222.222:80

In many default Apache configurations, the Listen and NameVirtualHost 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文