I want user to be able set up development sites on a server without the need for creating dns entries or apache vhost files. My current working solution to this has two elements.
Firstly creating a wildcard dns entry. This is a dns entry which starts with a wildcard “*” followed by the domain (or in this case subdomain).
*.devel.foo.com A 192.168.1.200
Any request to devel.foo.com will then be directed to the named server regardless of their prefix eg (project.a.devel.foo.com, kittenwar.devel.foo.com)
At this point the apache server receiving requests from these hosts will have no idea how to deal with them so we must create a dynamic vhost file. A detailed description of a dynamic vhosts can be found on the Apache site, but basically what it will do is take the server name from a request and use it to set the document path etc in the vhost dynamically. So using the configuration bellow
# get the server name from the Host: header
# this log format can be split per-virtual-host based on the first field
LogFormat “%V %h %l %u %t \”%r\” %s %b” vcommon
CustomLog logs/access_log vcommon
# include the server name in the filenames used to satisfy requests
project.a.devel.foo.com will point to the documents in directory
kittenwar.devel.foo.com will point to
/www/hosts/kitten.devel.foo.com/docs. So in effect this means all a developer has to do to have an accessible dev site is to create the proper name in the proper directory.