After following many outdated and incomplete instructions for setting up a web development environment on a Mac, and spending a lot of time finding solutions to the problems I encountered along the way, I decided to put together detailed tutorials for both Snow Leopard and Lion.

I started with a clean system, and the following are the steps that worked for me. If you run into an issue, or find an error in this tutorial, please let me know and I’ll update it.

Up until recently, the only way you could get the Command Line tools required for web development was via the full Xcode package, which is almost 2 GB in size. For Lion users, Apple now offers the Command Line Tools as a separate, much smaller download, which benefits those who don’t plan on writing Mac or iOS apps.