help with Virtual Hosts on Apache

Derek Broughton news at pointerstop.ca
Wed Mar 28 18:05:58 UTC 2007


Wade Smart wrote:

> On Tue, 2007-03-27 at 10:04 -0300, Derek Broughton wrote:
>> 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 *
> 
> Ok. So its supposed to look like this inside each file:
> 
> NameVirtualHost *

No, you only need one NameVirtualHost directive.  It just says you're going
to use name-based, rather than IP-based virtual hosts.

> <VirtualHost *>
> ServerName

There should be a name after ServerName.  So one of mine is:
      <VirtualHost *>
          ServerName plonevdc
          ServerAlias plonevdc.pointerstop.ca
      </VirtualHost>



> ServerAdmin webmaster at localhost
> ServerAlias siteA.com
> DocumentRoot /var/www/public_html/siteA.com
>   
> ScriptAlias /awstats/ /usr/lib/cgi-bin/

awstats is probably for your default site only - but maybe not.  

> 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?

Not likely.  Your default site should be using that servername or
serveralias.

ServerName and ServerAlias are the domains you can specify to reach the
virtual host.  ie, if you want to be able to use http://site1/ to get to
site1 and http://site2/ to get to site2, then site1 & site2 need to be in
your DNS (or /etc/hosts) as pointing to your local system and those will be
used for ServerName.  If you want site1.com and site2.com to work, you need
your DNS to resolve _those_ to your localhost, too (which gets more
complicated), and you make those ServerAlias entries.  I assume, though
I've never tried, that you can also use multiple ServerAlias directives to
allow other ways to reach the same site (eg, site1, site1.com and
www.site1.com all reaching the same domain).
-- 
derek





More information about the ubuntu-users mailing list