2014-12-30 128 views
0

當我重新加載的apache的顯示以下消息:警告了NameVirtualHost *:443具有沒有VirtualHosts

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

我檢查ports.conf文件和配置如下:

[email protected]:/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> 

爲什麼會出現以下警告,我該如何解決?

+0

http://httpd.apache.org/docs/2.4/mod/core.html#namevirtualhost – Deadooshka

回答

2

簡而言之:Apache正在443上進行偵聽,但在該端口上沒有定義VirtualHost(網站)。 (見/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 - 拆散的Apache從端口443 評論了「了NameVirtualHost *:443」和「聽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> 
+0

謝謝dovy。現在我明白了配置。簡單的Apache正在443上進行偵聽,但是在443上沒有定義啓用站點的虛擬主機。現在只是有點麻煩,在apache error.log中,我發現這個「[error] [client xxx.xx.xx.xx] File不存在:/var/www/favicon.ico「。 我這樣做是爲了解決這個問題:「touch /var/www/favicon.ico」。這是一個好的解決方案嗎? – Kiuki

+0

這些鏈接可能對您有所幫助:http://stackoverflow.com/a/11099560/3728901和http://serverfault.com/a/364427 –