1

I'm having problems getting my ServerAlias domains to work correctly. apache2ctl -S gives:

IP.ADDRESS:80      is a NameVirtualHost
default server byteinsight.net (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost byteinsight.net (/etc/apache2/sites-enabled/000-default.conf:1)
    wild alias *.byteinsight.uk
    wild alias *.byteinsight.co.uk
    wild alias *.bristolwebsitedesigner.co.uk
port 80 namevhost davies-barnard.co.uk (/etc/apache2/sites-enabled/000-default.conf:15)
    wild alias *.davies-barnard.uk
port 80 namevhost tdaviesbarnard.co.uk (/etc/apache2/sites-enabled/000-default.conf:30)
    wild alias *.greenotter.co.uk
port 80 namevhost weather.davies-barnard.uk (/etc/apache2/sites-enabled/000-default.conf:57)
port 80 namevhost weewx.davies-barnard.uk (/etc/apache2/sites-enabled/000-default.conf:70)
port 80 namevhost compu2learn.uk (/etc/apache2/sites-enabled/000-default.conf:84)
    wild alias *.compu2learn.co.uk
    wild alias *.compu2learn.org.uk

I've followed the guidance here and added the ServerName into the virtual host declaration e.g.

<VirtualHost byteinsight.net:80>...

and I have restarted Apache. I tried to add NameVirtualHost *:80 but was told it was not necessary and was going to be removed at the next update. I have also looked at this one and updated my settings to reflect the example given on the apache TroubleshootingVhosts page.

What have I missed?

Thanks

Chris

Byte Insight
  • 123
  • 7

1 Answers1

0

Ok, so I sussed this out in the end.

First I needed to heed the advice from VirtualHost ignores ServerName and ServerAlias and put the domain as listed in my main apache.conf file as global ServerName first in the virtual hosts file.

Main host goes away

If you are adding virtual hosts to an existing web server, you must also create a block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.

I also need to use full domains and not wild cards e.g.

ServerAlias www.domain.com domain.com 

and not

ServerAlias *.domain.com.
Byte Insight
  • 123
  • 7