radio tuner

Using MAMP to Build a local WordPress development environment

WebsitesCategory
4 min read
Douglas Karr

If you're looking to either develop plugins or themes and want to set up a test environment for WordPress, it's possible to do it locally on your PC or Mac. Similarly, if you're wanting to do some development and don't want to work directly on your live site, the local development approach might be for you.

MAMP (My Apache - MySQL - PHP) is a development environment that lets you manage your sites locally. Setting up a MAMP environment for WordPress on a local machine is a common approach to this issue.

Install and configure MAMP

Setting up MAMP is pretty straightforward. If you're on Windows or OSX, you can download and install MAMP 4.0.1 for Windows and MAMP 5.1 for Mac.

MAMP installs a local server environment in a matter of seconds on your computer. It comes free of charge and is easily installed.

MAMP will not compromise any existing Apache installation already running on your system. You can install Apache, PHP and MySQL without starting a script or having to change any configuration files! Furthermore, if MAMP is no longer needed, just delete the MAMP folder and everything returns to its original state.

For the purpose of this post, we're going to utilize MAMP, the freely distributed solution for setting up a personal web server. After you install MAMP, you'll see a simple user interface that allows you to start or stop your local Apache server, start or stop your MySQL database server, as well as modify a couple of options.

MAMP App Screen With Preferences Highlighted

Before we get started, I'd recommend modifying the preferences and ensuring that you enable the Apache and MySQL servers upon launching MAMP. This will help you avoid confusion when you can't seem to get WordPress up and running, and after 15 minutes figure out that the servers haven't been started. Click the Preferences icon and enable the checkbox for Start servers, then click OK.

MAMP Start/Stop Options

Next, click the Web Server tab. By default, MAMP will load the website from an htdocs subdirectory within the MAMP installation. This means that if you ever delete or overwrite that directory, you'll lose your work. My recommendation is to put a folder within your user's root directory, where you can easily find and update your files. I just called the folder Web.

MAMP Web Server Settings

Now that we're all set up, go ahead and click Start Servers and you'll see that an indicator is enabled on the Apache Server and MySQL Server on the top right of the MAMP status window.

MAMP App Screen With Stop Servers Highlighted

Your local Apache and MySQL servers are now running! A window should pop up in your default browser at the address:

http://localhost:8888/MAMP/
MAMP Welcome Screen With PHP and MySQL Configuration Status

Add your WordPress MySQL database

Within the MAMP start page, you'll see a link to phpMyAdmin, a web-based platform for managing your MySQL database(s).

  1. Click the link and open phpMyAdmin.
  2. In the left-hand menu, click New, name your database, and set the type to utf16_general_ci. We called our database wp_local.
MAMP phpMyAdmin

Install and configure WordPress

  1. Download and unzip the version of WordPress you wish to run locally within the Web Server folder you identified when configuring MAMP. When you unzip the file, WordPress will be contained in a WordPress folder.
  2. Click on the My Website link within your MAMP browser start page navigation. This will open up the directory that you've installed WordPress within.
  3. Navigate through all of your settings and fill in the appropriate fields, including database name wp_local, database username root, database password root, and database host localhost.
MAMP WordPress Database Configure
  1. Clicking Submit will result in a confirmation message where WordPress warmly calls you Sparky, and lets you know that your database connection worked and it's time to set up WordPress.
  2. Now you're set! You can set your normal WordPress site settings, login credentials and get started!

A note on using MAMP to test WordPress beta versions

If your plan is to utilize this installation for beta testing, be sure to download, install and activate the WordPress Beta Tester plugin on the local machine. It will provide you notifications for both alpha and beta releases as well as the installation of nightly builds of them.

Having a local development environment is a key element in your toolkit if you're a WordPress developer. Let me know in the comments how things worked for you with MAMP!