[vox-tech] apache2: NameVirtualHost and VirtualHost

Peter Jay Salzman p at dirac.org
Sat Nov 18 21:31:59 PST 2006


I'm trying to understand NameVirtualHost and VirtualHost.

Suppose I have a server with hostname "satan", IP address "192.168.0.2"
that serves two sites:

   www.dirac.org          with  DocumentRoot /www/
   www.foo.org            with  DocumentRoot /www/foo

And I have the following entry in /etc/hosts:

   192.168.0.2  satan.diablo.localnet satan dirac.org www.dirac.org

The sites-enabled files look like:

   # /etc/apache2/sites-available/dirac.org
   <VirtualHost dirac.org>
      DocumentRoot /www
      ServerName   www.dirac.org
      ServerAlias  dirac.org *.dirac.org
      ...
   </VirtualHost>
   

   # /etc/apache2/sites-available/foo.org (doesn't work)
   <VirtualHost foo.org>
      DocumentRoot /www/foo
      ServerName   www.dirac.org
      ServerAlias  dirac.org *.dirac.org foo.org *.foo.org
      ...
   </VirtualHost>


Why is the NameVirtualHost directive necessary and how do I use it?

Thanks!
Peter


More information about the vox-tech mailing list