Local Web Development with OS X Yosemite

My guide for setting up a great web development environment on your Mac, which was originally written with OS X 10.8 (Mountain Lion) in mind, updated for Mavericks, has been overhauled (and simplified) for OS X 10.10 (Yosemite), which now comes with Apache 2.4.

The tutorial now uses Homebrew, but since I spent some time figuring out how to get MacPorts running under Yosemite, I might as well share that here. The MacPorts package installer did not work under Yosemite (as of October 2014), but there is a workaround. You can download, and install the tarball. Unzip it, jump into that directory in terminal, and run the following commands to install MacPorts in Yosemite. You’ll need to enter your admin password.

./configure && make && sudo make install
export PATH=/opt/local/bin:/opt/local/sbin:$PATH

If your carefully crafted localhost has stopped working, after the upgrade, it’s likely that you may need to restore your Apache config files.

When the Yosemite updater runs, it replaces your edited Apache configuration file with the default one, wiping out any changes you have made. The good news is that there is a back up of your config files.

Running the following commands will restore your pre-upgrade Apache configuration, and restart apache:

sudo cp /etc/apache2/httpd.conf.pre-update /etc/apache2/httpd.conf
sudo apachectl restart

This alone should restore your settings, and kick start your old environment under Yosemite.

If you have not yet upgraded, I would encourage you to first make your own backup of your config file, just in case your upgrade fails, and you need to start from scratch.