I have an Apache 2.2 server that works but I am getting the NameVirtualHost *:443 has no VirtualHosts
warnings when restarting. But I do have VirtualHosts that match *:443
.
The system is Debian squeeze. The ports.conf
file looks like this:
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
NameVirtualHost *:443
Listen 443
</IfModule>
Here is the output when running the -S
option with apache2ctl:
% /usr/sbin/apache2ctl -S
[Sat Mar 06 10:07:11 2013] [warn] NameVirtualHost *:443 has no VirtualHosts
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443 is a NameVirtualHost
default server q2a-dev.example.org (/etc/apache2/sites-enabled/q2a:1)
port 443 namevhost q2a-dev.example.org (/etc/apache2/sites-enabled/q2a:1)
port 443 namevhost tcert-dev.example.org (/etc/apache2/sites-enabled/tcert-dev:1)
*:80 is a NameVirtualHost
default server emailtest-dev.example.org (/etc/apache2/sites-enabled/emailtest:1)
port 80 namevhost emailtest-dev.example.org (/etc/apache2/sites-enabled/emailtest:1)
Syntax OK
The two virtual hosts are defined in files living in /etc/apache2/sites-enabled
:
# /etc/apache2/sites-enabled/q2a
<VirtualHost *:443>
DocumentRoot /usr/share/question2answer
ServerName q2a-dev.example.org
ServerAlias q2a-dev
SSLEngine on
SSLCertificateFile /etc/ssl/certs/q2a-dev.pem
SSLCertificateKeyFile /etc/ssl/private/q2a-dev.key
DirectoryIndex index.php
</VirtualHost>
and here is the another one:
# /etc/apache2/sites-enabled/tcert-dev
<VirtualHost *:443>
DocumentRoot /srv/www/tools
ServerName tcert-dev.example.org
ServerAlias tcert-dev
SSLEngine on
SSLCertificateFile /etc/ssl/certs/tcert-dev.pem
SSLCertificateKeyFile /etc/ssl/private/tcert-dev.key
<Directory "/">
AllowOverride None
</Directory>
</VirtualHost>
I found the problem. After Andrew B suggested posting more of the configuration on pastebin I looked through all the files more carefully and found that I had TWO places where the
NameVirtualHost *:443
directive appeared: one inports.conf
and one in a file in the directory/etc/apache2/conf.d
all files of which are loaded during Apache start-up.I removed one of the instances and the warning went away.
(Note that this whole issue goes away in Apache 2.4 as
NameVirtualHost
is implicit for address/port combinations appearing in multiple virtual hosts.)I use Debian Squeeze too, please see below how my
ports.conf
looks like.The comment comes from the default file, note that you added
NameVirtualHost *:443
, I didn't.Note: in case you prefer to keep
NameVirtualHost *:443
inports.conf
then you should add a link in order to have a default VirtualHost for 443 as follows:Then I would update
/etc/apache2/sites-enabled/q2a
by adding<Directory>...</Directory>
(it's where you put some options, I completed your code by adding some examples).Finally I would change
/etc/apache2/sites-enabled/tcert-dev
by updating the document root in<Directory>...</Directory>
.I hope it helps.
That is a warning saying there are no virtualhosts setup for *:443
It would look something like
If it doesn't match *:443 then it will throw that warning.