So, I've started using Apache's dynamically configured mass virtual hosting. This gets me two things. First, I don't need to make any changes in Apache's configuration file when I want to setup a new local web application. Second, I now have an easy-to-remember naming convention for sites that are running locally. This works really well for me, but your mileage may vary depending on your specific needs. There are also other tools that can help you accomplish similar results, but I like the simplicity of this in that it doesn't require anything other than Apache and some DNS settings.
Let me explain the end result first, and then I'll explain how I got there. For each website I work on I use the subdomain to indicate the environment it's running in. Using the domain example.org we may have the following environments setup:
- local.example.org - the local copy
- beta.example.org - a semi-publicly available beta
- www.example.org - the live site
The downside of this is that you would need to update the host file on each machine that you wanted to run the local.example.org site on. A comprimise would be to run your own recursive DNS service that only your computers used and make the DNS entries there.
This next step only needs to be done once. The dynamically configured mass virtual hosting article explains in detail how to set this up. My Apache configuration looks something like this:
Again, your specific configuration may be different. When making a request to http://local.example.org/ the document root would expand to /path/to/workspace/example.org/public. This assumes that you have placed all of your projects in the same location and they all have a similar directory layout (I'm using Zend Framework's directory layout). I think there's a way to do this in a way that's more flexible, but I haven't had the need. Let me know if you have any questions!