Craig Buckler at Sitepoint described one method of using the hosts file on your PC and Apache’s NameVirtualHosts feature to ease complexity of working with more than one Apache HTTPD locally hosted web project. The method he describes is very usable, but it adds an external dependency for your projects and it’s not the way I’ve been working.
Since I tend to work only on one site at a time, I have developed scripts to start up the correct versions of Apache, PHP, MySQL etc. that each project requires (depending on where it will eventually be hosted) and pull in the correct configuration for each of those components.
Each project has its own Apache configuration file which reads in a master Apache configuration using the Include directive, before applying project specific changes.
In the development environment for this site, johngirvin.com, I have the following Apache configuration:
# master configuration Include c:/foo/_conf/apache-2.2.08.conf Include c:/foo/_conf/php-5.2.6/apache.conf # project specific configuration Listen 80 DocumentRoot c:/foo/johngirvin.com/trunk/httpdocs/ ...
In the past I’ve also used one configuration file with different Listen ports for each virtual host, which avoids making any changes to the hosts file and has minimal project specific configuration, but gets unwieldy as the number of hosted sites grows and you have to remember which site lives on which port.
I’ve since found it easier to use the above “layered modular configuration” approach. Furthermore, it permits using different versions of Apache, PHP and MySQL – or even alternatives such as Ruby, Python, PostgreSQL etc. – for different projects on one workstation.
The best solution, as ever, depends on your needs.


This is similar to how the version of Apache2 shipped with Debian works: a separate configuration for each virtual host.
`sudo apache2ctl -S` on *nix will tell you which ports & names are being listened for & the corresponding document roots. Dunno what the equivalent on Windows is though…
Quite often I’ll add entries into my hosts file and use named virtual hosts instead of having httpd listening on a huge number of ports.