Virtualhosts on Mac OS X

Matthew just posted a quick write up of setting up virtual hosts on windows and a little of the rationale behind why you would bother.

Being a Mac person when I’m not in the office I thought a quick follow up would be useful for those that way inclined.

On OS X their are a couple of things needed to setup a virtual host. As well as the apache virtualhost directives the host needs adding to NetInfoManager.

Although you can do all of this manually I’m more of a fan of a quick shell script and, as it happens, so are others. I’ve been using a modified version of Patrick Gibsons Virtualhost’s script for a while. Just drop it somewhere on your path (or run it from a specific folder) from Terminal like so:

sudo virtualhost.sh morethanseven.dev

Where morethanseven.dev is the local domain you want setting up. The default version of the script makes the assumption that you are using the default web server which comes with OS X. I’m not, but it’s easy enough to modifiy the configuration parameters at the top of the (well commented) script to point where you want. I have it working perfectly with a copy of the MAMP installation package for instance.

I’m something of a fan of utility scripts. Often repeated tasks can be bundled up into a shell script, python script or automator workflow. Automatic screen capture? Batch image processing? Backup? It can help keep everything tidy, as well as minimising repeated effort. Anyone else with any good examples of process automation with regards web design want to share?