Configuring a Local Apache/PHP/MySQL Dev Environment in OS X

Update: If you’re just getting started now, I strongly recommend looking into Vagrant instead of rolling your own environment like I describe. I still use the exact environment I detail below, but am leaning towards Vagrant soon. If you’re a WordPress developer, specifically check out Varying Vagrant Vagrants (VVV) by 10up.



These are my personal notes that I use every time I reformat or get a new computer. I’ve curated these instructions over the course of 4 years, so they are littered with links to relevant source material and have been stripped down to the exact actionable steps I need to take to get up and running. As such, this post is mostly for my own benefit, and I will regularly update it as my process changes (usually with each new OS X release).

These instructions have been updated to specifically support OS X Mavericks (10.9), but will work with Mountain Lion (10.8), Lion (10.7), Snow Leopard (10.6), and Leopard (10.5). Running 10.4 or lower? You should probably upgrade 🙂

I might write some follow-up posts about using this setup to create a killer local WordPress Multisite installation, and also porting your dev environment contents to live in DropBox. If so, I’ll link them up here.

Why not just use MAMP?

If you’re wondering, I like to set up my local environment, instead of using MAMP, because I prefer to have it always available. I never liked having a separate application running just so I could access my local dev setup. Also, it has always bothered me that MAMP bundled its own copies of PHP, Apache and MySQL when the only missing component that doesn’t come pre-loaded with OS X is MySQL.

Help, I’m stuck!

It’s worth mentioning here that I’m not a very smart guy, which is why I’ve kept these detailed notes for the last 4 years. These instructions work for me, but they might not work for you. If you get stuck with an issue, I suggest googling around and sharing what you discover here in the comments. It will likely be much faster than asking me for help, and will benefit everyone who reads this (me included)!

A Quick Word about my Terminal Commands

In many of the terminal instructions I use my custom bash shortcut “sub” to open a given file in Sublime Text 2 via command line. You can substitute “sub” for your text editor of choice (e.g. “vi” for Vim, or “mate” for TextMate, or “subl” for the standard Sublime shortcut).

Install MySQL

Follow these steps, in order:

  1. Download DMG installer from
  2. Install MySQL
  3. Install MySQL auto-start
  4. Install MySQL pref pane
  5. Then, configure MySQL:
  6. In Terminal: sub ~/.profile
    1. Add this line to the file: export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
    2. Save and close the file.
  7. In Terminal: source ~/.profile
  8. Finally, configure MySQL socket (because OS X is looking in the wrong directory):

Configure PHP

These steps are really only to keep you sane while testing uploads and such in your projects:

  1. In Terminal: sudo cp /etc/php.ini.default /etc/php.ini
  2. In Terminal: sub /etc/php.ini
  3. Update upload_max_filesize to something like 64MB (L891 in OS 10.8)
  4. Update post_max_size to something like 64MB (L740 in OS 10.8)
  5. Save and close

Configure Apache

Update httpd.conf to enable PHP5 and Virtual Hosts:

  1. In Terminal: sub /etc/apache2/httpd.conf
  2. Uncomment the include for PHP5 (L117 in OS 10.8, L111 in older releases)
  3. Uncomment the include Virtual Hosts (L477 in OS 10.8, L623 in older releases)
  4. Save and close the file.
  5. If you’re running OS X 10.7 or earlier, you’ll also need to enable “Web Sharing” in System Preferences > Sharing.

Setup Virtual Hosts (

Update: If you’d rather have “*.dev” dynamically mapped to “~/Sites/www/*”, check out this great article on Apache zero-config development. Then, follow this article on using DNSmasq to redirect all .dev traffic locally.

For the example below, you’ll want to replace “” with your own custom URL, and “username” with your own OS X username.

  1. In Terminal: sub /private/etc/hosts
  2. Add the following line to the file:
  3. Save and close the file.
  4. In Terminal: sub /private/etc/apache2/users/username.conf
  5. Add the following lines to the file:
    1. <Directory "/Users/username/Sites/">
          Options FollowSymLinks Indexes MultiViews
          AllowOverride All
          Order allow,deny
          Allow from all
      <VirtualHost *:80>
         DocumentRoot "/Users/username/Sites/"
  6. Save and close the file.
  7. Finally, flush the DNS cache & Restart Apache (you’ll want to do this any time you edit your hosts file and virtual hosts setup):
    1. In Terminal: dscacheutil -flushcache
    2. In Terminal: sudo apachectl restart

In my setup I’ve registered to point to my ~/Sites/ folder, rzen.wp to point to ~/Sites/wordpress/, and rzen.php to point to ~/Sites/phpMyAdmin. This means I’ve created a separate pointer for each domain in my hosts file, and a separate <VirtualHost> container for each in my apache .conf file.


Apache Error Notes

Later, if apache ever goes south and starts spitting 403 Forbidden, or some other error, check the error log. You can open it from inside Terminal: sub /var/log/apache2/error_log

If the problem is “Symbolic link not allowed or link target not accessible”, confirm that your symlinked folder, it’s parent directory, et al, have sufficient permissions for owner and group (

Upgrading OS X?

Be aware that with every upgrade OS X is likely to overwrite your edits to Apache’s httpd.conf file. Specifically, you’ll probably need to edit /etc/apache2/httpd.conf once again and uncomment the lines for including PHP (L118) and enabling Virtual Hosts (L478).

This has at least been true both for upgrading to OS X Mountain Lion (10.8) and OS X Mavericks (10.9), and probably true in upgrading to releases before those.

The Optional (but recommended) Bits

Install Sequel Pro

This app is amazing, and it works brilliantly for manipulating both local and remote databases. And it’s free!
Download Sequel Pro

Install phpMyAdmin (if you hate living in the future and using Sequel Pro)

  1. Download latest version of phpMyAdmin from
  2. Unzip to ~/Sites/phpMyAdmin/
  3. Rename to
  4. On L36 change $cfg['Servers'][$i]['AllowNoPassword'] to true
  5. By default, your login will be root with no password

Install WordPress

  1. Download the latest version of WordPress from
  2. Unzip to ~/Sites/wordpress/
  3. Create a new database for your install via phpMyAdmin to use during installation
    • Database server will be localhost
    • Username will be root
    • Password will be blank
  4. Pro-Tip: Once installed, edit wp-config.php add define('FS_METHOD','direct'); somewhere before the “That’s All, stop editing here” comment. This will enable direct access to the file system when running automatic updates and make your local dev experience mui guapo.

Install Git

Visit and download + install the latest version. Done.

Install SVN

For some reason, beginning in Mountain Lion (OS X 10.8), Apple stopped packaging SVN with Mac OS. So, you’ll need to download “XCode Command Line Tools” separately by signing in as a Developer (after registering for a free account using your Apple ID) here:

Alternatively, you can download SVN directly from WanDisco: I recommend using 1.7+.

Enable SSL

If you ever have need to test a site or service locally using https://, my co-worker @jtsternberg has written up a wonderfully detailed step-by-step of his experience doing just that. You can read it here: How to set up SSL with OSX Mountain Lion’s built-in Apache