help with Virtual Hosts on Apache

Wade Smart wade at wadesmart.com
Wed Mar 28 16:56:21 UTC 2007


On Tue, 2007-03-27 at 10:04 -0300, Derek Broughton wrote:
> 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
> 
> 
03282007 1151 GMT-6 DST

This is a bit confusing. I was reading the apache documentation and it
still says that all of this is in the httpd.conf. That doesnt help. 

Ok. So its supposed to look like this inside each file:

NameVirtualHost *

<VirtualHost *>
ServerName  
ServerAdmin webmaster at localhost
ServerAlias siteA.com
DocumentRoot /var/www/public_html/siteA.com
  
ScriptAlias /awstats/ /usr/lib/cgi-bin/
  
CustomLog /var/log/apache2/siteA.com-access.log combined
</VirtualHost>


Now just one question. This IS my personal computer so is the server
name the same as whats on my terminal, which is wadesmart at wadesmart: ~$
making my server name wadesmart?

wade





More information about the ubuntu-users mailing list