【问题标题】:warn NameVirtualHost *:443 has no VirtualHosts警告 NameVirtualHost *:443 has no VirtualHosts
【发布时间】:2014-12-30 10:17:53
【问题描述】:

当我重新加载 apache 时出现以下消息:

Reloading web server config: apache2[Tue Dec 30 10:24:04 2014] [warn] NameVirtualHost *:443 has no VirtualHosts

我查看了ports.conf文件,配置如下:

root@li277-183:/etc/apache2# cat ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost *:80
NameVirtualHost *:443
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

为什么会出现以下警告,我该如何解决?

【问题讨论】:

标签: apache


【解决方案1】:

简单地说:Apache 正在侦听 443,但该端口上没有定义虚拟主机(网站)。 (见/etc/apache2/ports.conf):

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    NameVirtualHost *:443
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    NameVirtualHost *:443
    Listen 443
</IfModule>



我有两种解决方案:

解决方案 1 - 启用默认 SSL 配置(首选,破坏性较小) 在 443 上定义一个站点(最简单的方法是运行以下代码):

ln -s /etc/apache2/sites-available/default-ssl 000-default-ssl

然后重启apache

/etc/init.d/apache2 restart



解决方案 2 - 从端口 443 取消绑定 Apache 注释掉 /etc/apache2/ports.conf 的 "NameVirtualHost *:443" 和 "Listen 443" 行(例如,在这些行中添加 # 符号,以便新的端口配置文件看起来像这样:)

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # NameVirtualHost *:443
    # Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    # NameVirtualHost *:443
    # Listen 443
</IfModule>

【讨论】:

  • 谢谢你。现在我已经了解了配置。只是 Apache 正在监听 443,但在 443 上启用的站点中没有定义 VirtualHosts。现在有点麻烦,在 apache error.log 中我发现这个“[error] [client xxx.xx.xx.xx] 文件确实不存在:/var/www/favicon.ico”。我这样做是为了解决这个问题:“touch /var/www/favicon.ico”。这是一个好的解决方案吗?
  • 这些链接可能对您有帮助:stackoverflow.com/a/11099560/3728901serverfault.com/a/364427
  • 只想添加 NameVirtualHost *:443 应该在 Listen 443 之前
猜你喜欢
  • 1970-01-01
  • 2011-11-02
  • 2014-01-02
  • 2012-10-29
  • 2013-03-23
  • 1970-01-01
  • 2023-03-24
  • 2022-12-02
  • 1970-01-01
相关资源
最近更新 更多