Centos – NameVirtualHost *:80 and 443 has no VirtualHosts on centos

apache-2.2centos

Since I added IPs to my server, I have a lot of issues when starting apache.

I always have these errors below:

[warn] NameVirtualHost *:443 has no VirtualHosts
[warn] NameVirtualHost *:80 has no VirtualHosts

Sometimes it prevents apache to start, and sometimes not

My conf:

OS : CentOS 6.6

Apache : 2.2.15

My httpd.conf:

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
    ServerName www.domain.com
    ....
</VirtualHost>
#more than 500 others <VirtualHost *:80> for each domain

Best Answer

Your config can work for some times, but mostly it unworkable. Working config look like:

NameVirtualHost *:80

<VirtualHost *:80>
   ServerName www.domain.com
   ....
</VirtualHost>


NameVirtualHost *:443

<VirtualHost *:443>
      ServerName www.domain.com
      ....     
<VirtualHost *:443>   

Or made separate file for vhosts.conf (In centos your path for file will be /etc/httpd/conf.d/vhosts.conf). If you need separate tls certificate for every virtual host you need some additional changes.