Linux – Apache2 / debian wheezy serving only default virtual host

apache-2.2debian-wheezylinuxvirtualhost

I have seen all other questions around this topic, but none of the answers have worked.

Situation: VPS on 1 IP, debian wheezy 7 running with apache2.

Even simple virtualhost will not work, as named in sites-enabled "www.domain.net":

<VirtualHost *:80>
ServerName domain.net
ServerAlias www.domain.net
DocumentRoot /var/www/domain
</VirtualHost>

Output of apache2ctl -S :

VirtualHost configuration:
xx.xx.xxx.xxx:443     is a NameVirtualHost
default server xx.domain1.net (/etc/apache2/conf.d/owncloud5-ssl.conf:1)
port 443 namevhost xx.domain1.net (/etc/apache2/conf.d/owncloud5-ssl.conf:1)
xx.xx.xxx.xxx:80      oc.domain1.net (/etc/apache2/sites-enabled/oc.domain.net:8)
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
     default server domain1.net (/etc/apache2/sites-enabled/000-default:8)
     port 80 namevhost domain1.net (/etc/apache2/sites-enabled/000-default:8)
     port 80 namevhost mail.domain2.net (/etc/apache2/sites-enabled/mail.domain2.net:8)
     port 80 namevhost domain2.net (/etc/apache2/sites-enabled/www.domain2.net:1)
Syntax OK

Still is the index.html in /var/www served as the default virtual host (domain1). Which should indeed be the catch all virtual host. But domain2 and subdomains of both domains are not picked up by apache2. All domains have an A-name in DNS setting, all pointing to same public IP. All resolves to this ip and to default virtual host.

Best Answer

If i remember this is called virtualhost over-laping, when i used NameBased virtual host, i solved the problem creating a simple default virtualhost like this

<VirtualHost _default_:*>
   DocumentRoot /www/default
</VirtualHost> 

for more information you can read apache official docs http://httpd.apache.org/docs/2.2/vhosts/examples.html

Related Topic