apache virtual directories / VirtualHost overlap

Jonathan Horne jhorne at dfwlp.org
Wed Jan 9 08:36:21 PST 2008


Jonathan Horne wrote:
> zbigniew szalbot wrote:

>>> >
>>> > So I defined:
>>> >
>>> > NameVirtualHost 83.19.156.210
>>> >
>>> > <VirtualHost 83.19.156.210>
>>> >     ServerAdmin webmaster at dummy-host.example.com
>>> >     DocumentRoot /usr/local/www/data/
>>> >     ServerName lists.lc-words.com
>>> >     ErrorLog /var/log/httpd-error.log
>>> >     CustomLog /var/log/httpd-access.log common
>>> > </VirtualHost>
>>> >
>>> > <VirtualHost 83.19.156.210>
>>> >     ServerAdmin webmaster at dummy-host.example.com
>>> >     DocumentRoot /usr/local/www/data/blog/
>>> >     ServerName blog.lc-words.com
>>> >     ErrorLog /var/log/httpd-error.log
>>> >     CustomLog /var/log/httpd-access.log common
>>> > </VirtualHost>
>>> >

also, try this setting up a vhost for the actual host, then 'child' 
vhosts for the different sites that you want to host. an example:

# Virtual Hosts
NameVirtualHost *:80

# VH for actualhost.example.com
<VirtualHost *:80>
     ServerName actualhost.example.com
     UserDir disable
     DocumentRoot /usr/local/www/apache22/data/
     ErrorLog /var/log/httpd/error.log
     CustomLog /var/log/httpd/actualhost.example.com_log combined
</VirtualHost>

# VH for blog
<VirtualHost *:80>
     ServerName blog.example.com
     UserDir disable
     DocumentRoot /usr/local/www/blog
     ErrorLog /var/log/httpd/error.log
     CustomLog /var/log/httpd/blog.example.com_log combined
</VirtualHost>

# VH for lists
<VirtualHost *:80>
     ServerName lists.example.com
     ServerAlias lists.example.com
     DocumentRoot /usr/local/www/lists
     ErrorLog /var/log/httpd/error.log
     CustomLog /var/log/httpd/lists.example.com_log combined
</VirtualHost>

i believe the specifying ServerName is critically important to 
sucessfully wrangling all your vhosts into the proper DocumentRoot(s).

hth,
-- 
Jonathan Horne
http://www.dfwlp.org
jhorne at dfwlp.org


More information about the freebsd-questions mailing list