June 19, 2007
WebDev: OS X Local Server Management with Headdress
After working through my OS X sandbox setup post earlier today, which involves manual setup of the Apache configuration files, I was alerted to a nice little application called Headdress.
I gave it a quick demo, and given it’s short price tag, I purchased it so I could put it through it’s paces, and really understand what it does (and doesn’t) do.
Headdress does one thing and does it well. It provides a simple interface for editing and managing a local apache webserver allowing you to running multiple sites on your local server. The most common use for this type of configuration is for local web development of multiple websites.
By default Headdress uses the Apache server that comes bundled with OS X and configures it to run each website on a different port. Therefore, if you have a number of websites running locally, they’ll be accessible via a sequential set of ports, for example:
http://localhost:9000
http://localhost:9001
http://localhost:9002
…
The basic functionality requires only that you point it to a directory where the website’s root lives and it does the rest. It has advanced options that allow you to more thoroughly configure your server by controlling the hostname, ports, etc.
You can even manage multiple apache installations, and it works nearly seamlessly with a second server, like MAMP.
All you have to do is point Headdress at the MAMP httpd.conf file and it works like a charm. It even pulls in any existing virtual hosts that are configured in MAMP.

Ports vs. Local Hostnames
To accomplish having multiple sites on a single web server without resorting to nested directories, Headdress uses a different port for each server. This nice simple solution unfortunately leaves you with an unintuitive naming scheme for accessing each site.
You must somehow remember, or be reminded, which port a site is running on. This has lead people to come up with creative schemes to keep track of them like this snazzy Headdress-Quicksilver hack by Shaun Inman.
My manual solution accomplishes running multiple sites on a single port, but setting up different local host names using the OS X netinfo manager. So instead of having to remember different port addresses, I create additional machine names in OS X netinfo manager, all pointing to the local IP 127.0.0.1. Using this method, I am able to access my sites with a more memorable naming convention with no ports to bother with, for example:
http://site1.dev
http://mycoolsite.dev
http://bagowetmice.dev
I simply replace the TLD (.com) with the dummy TLD .dev. And with some very simple configuration, my computer knows that each of those domains point to the local server. Apache’s virtual host configuration serves up the correct site based on the name instead of the port number.
My solution is also fully compatible with Headdress thanks to its advanced configuration settings. I can give it the hostname that I created and the port that the server is running on (ideally, port 80 so it doesn’t have to be specified at all).
Other Headdress Conveniences
In addition to eliminating all the Apache config file editing, Headdress provides a nice quick interface for editing these sites. It has an edit link which launches Textmate with that site as a project.
Conclusion
Headdress is a nice clean application that does just what it sets out to do and makes short work of setting up multiple development sandboxes on a local Mac.
I do think a great improvement would be to leverage the local DNS settings to allow name-based virtual hosting instead of using port numbers. Automate this configuration without having to edit the machines in netinfo manager and it’s money.
If you enjoyed this post, please subscribe to my RSS feed
It’s a decent application, yes.