help with Virtual Hosts on Apache

Derek Broughton news at pointerstop.ca
Tue Mar 27 13:04:24 UTC 2007


Wade Smart wrote:

> 
> So I did this with these specifics:
> <VirtualHost dale.com>
>   ServerAdmin webmaster at localhost
>   ServerAlias www.dale.com
>   DocumentRoot /var/www/public_html/example.com
>   ScriptAlias /awstats/ /usr/lib/cgi-bin/
>   CustomLog /var/log/apache2/example.com-access.log combined
> </VirtualHost>
> 
> and under /etc/hosts I added
> 127.0.0.1 sam.com dale.com
> 
> Problem is, what happens when I add a second and a third entry?
> 
> I created a second entry and received this error after restarting
> apache:
> 
> [Mon Mar 26 18:34:24 2007] [warn] VirtualHost dale.com:0 overlaps with
> VirtualHost sam.com:0, the first has precedence, perhaps you need a
> NameVirtualHost directive
> 
> Am I doing this wrong?

Yes :-)

It's 

<VirtualHost *>
...
</VirtualHost>

That doesn't look obvious, but it's correct.  The actual virtual host name
is taken from the ServerName (which you don't have) and ServerAlias
directives.

You also need the NameVirtualHost directive, as stated.  It's usually just:

NameVirtualHost *

-- 
derek





More information about the ubuntu-users mailing list