· Jonathan Cutrer · WordPress  · 2 min read

Setting Up a Local WordPress Dev Environment with MAMP

If you're still editing WordPress files directly on a live or staging server, stop. Here's how to get a local stack running on your Mac with MAMP in under 20 minutes.

This post was originally published in September 2015 and is part of the legacy archive migration.

For years I edited files directly on a staging server. It worked until it didn’t. One bad edit to functions.php brought down a client site at 11pm on a Thursday. After that, local development became non-negotiable.

MAMP (Mac Apache MySQL PHP) was my first serious local stack on Mac. The free version handles PHP, MySQL, and Apache well enough for WordPress development. You can grab it from mamp.info. Installation is drag-and-drop into Applications — nothing to configure from the command line. Once it’s running, you get Apache on port 8888 and MySQL on port 8889 by default, though I immediately change those to 80 and 3306 to match a typical server environment.

To get WordPress running locally:

  1. Download WordPress from wordpress.org and unzip it into /Applications/MAMP/htdocs/mysite
  2. Open phpMyAdmin (the button is right in the MAMP control panel) and create a new database — I call mine wp_mysite
  3. Copy wp-config-sample.php to wp-config.php and fill in the database name, user (root), and password (root by default in MAMP)
  4. Visit http://localhost:8888/mysite and run through the WordPress installer

The one thing that trips people up is the DB_HOST setting. In wp-config.php, set it to 127.0.0.1:8889 if you’re using MAMP’s non-standard port, not just localhost. MySQL socket behavior on Mac can be finicky otherwise.

After that, development is just editing files in your htdocs folder. I keep mine synced to a git repo and push to staging only when something is actually working. It’s a slower feedback loop than editing live, but that’s the point.

Back to archive