Forum Moderators: bakedjake
the apache group has this in their docs for apache webserver. there is an intro on the topic in a whole article. it's called Apache Virtual Host documentation [httpd.apache.org].
i think you should read this. anyway, for domain name based virtual hosting, the following directives are used:
...
Port 80
ServerName server.domain.tld NameVirtualHost *
<VirtualHost *>
DocumentRoot /www/domain
ServerName www.domain.tld
...
</VirtualHost>
<VirtualHost *>
DocumentRoot /www/subdomain
ServerName www.sub.domain.tld
...
</VirtualHost>
this example is taken out of the docs and handles a toplevel domain and a subdomain. but much more is possible, ie you could setup multiple domains in one virtualhost section.
in your zone file:
* IN A 192.0.34.166
IN HINFO "p166mmx" "Debian 3.0"
@ IN A 192.0.34.166
IN HINFO "p166mmx" "Debian 3.0"
in httpd.conf:
NameVirtualHost 192.0.34.166:80
<VirtualHost example.com:80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/www.example.com
ServerName www.example.com
ServerAlias example.com
</VirtualHost>
<VirtualHost devel.example.com:80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/devel.example.com
ServerName devel.example.com
</VirtualHost>
<VirtualHost other.example.com:80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/other.example.com
ServerName other.example.com
</VirtualHost>
These are based on my own working zone file and httpd.conf fragments, munged to fit example.com rather than my own domain and IP addresses. The ":80" that shows up in my httpd.conf could be omitted in many circumstances - in my configuration it can't, because port 443 uses IP-based virtual hosts. (I've got more virtual hosts than you can shake a stick at.) The "DocumentRoot" paths are purely hypothetical, and should match whatever directory you're keeping the files in for that vhost. The zone file fragment would expect to be used for the zone 'example.com'.