Installing WordPress with MAMP on Mac OS X

This is an absolute beginners tutorial on how to get yourself a local WordPress development environment set up on your Mac OS X with MAMP. Step by step (and with screenshots,) we’ll go through each part of the process — downloading and installing MAMP, basic MAMP configuration, creating a MySQL user and database, getting WordPress up and running, and in the end I’ll share some tips you might find useful in your WordPress journey.

What is MAMP and why MAMP?

WordPress is not a stand-alone application. In order to work, it requires a special set of server software that your hosting company will typically provide for you, but such software is not pre-installed on your local Mac. This means that in order to run WordPress locally, you would need to install and configure the set of software yourself, but luckily there’s MAMP!

MAMP is a stand-alone application for Mac OS X which brings server power to your home or office desktop or laptop. It bundles the typical software stack you’d need to run all sorts of web applications including WordPress; that is the Apache web server, a MySQL database server and a PHP interpreter. As you might have noticed, those three are the “AMP” part. The first “M” stands for Macintosh, or as we call it nowadays — Mac.

Installing MAMP

If you’re a Mac user, you’ve probably gone through the process of installing new software in OS X, and MAMP is not too different. Let’s browse to the MAMP website and get ourselves the latest copy of the software. It’s usually bundled with MAMP PRO trial (a commercial and more advanced) version, but we’ll be using the free version which is enough to get you started.

Download MAMP

Once the download is complete (over a hundred megabytes,) extract the contents of the archive somewhere, your desktop is a good place. You’ll see that it contains a MAMP.pkg package which you can run. You’ll be greeted with a user-friendly installer where you’ll have to keep hitting Continue to get through each step.

Note that during the Installation Type step, you can hit Customize and uncheck MAMP PRO which would skip the trial commercial package.

Installing MAMP

After MAMP has been installed, you can launch it using the Applications tab in your dock or by searching for MAMP in Spotlight. Note that when starting and stopping services and changing the configuration, MAMP may ask you for your password, which is required to make system changes in OS X.

MAMP Configuration Password

The Status section on the left will show you when the Apache and MySQL services are started or stopped. After changing any configuration, you might need to restart the servers for your changes to take effect.

Configuring Apache & MySQL Ports

This step is quite important. By default MAMP sets non-default ports for Apache and MySQL in order to avoid possible conflicts with other running applications, so unless you’re using some software that occupies the default ports, it would be nice to change them. Apache to port 80 and MySQL to port 3306.

Use the Preferences button, and then the Ports tab to make the necessary changes. MAMP will have to restart your servers for the changes to take effect.

MAMP Ports Setup

Now while you’re at the MAMP preferences, hit the Apache tab to be able to select a directory root. This is like the public_html folder on your web hosting server, but a local one. That’s where you will install WordPress and store all your project files. A folder in your Documents is a good place to start. I’ll call it my_document_root.

To make sure everything is working correctly, let’s create a new PHP file in the directory we just set as our document root. Call the file index.php and have its contents say something simple:

<?php phpinfo(); ?>

Then get your web browser to point to localhost and if you’re lucky enough you’ll see the PHP info page that looks like this:

phpinfo with MAMP

Hurray, now delete that file and let’s get a MySQL database ready for WordPress.

Creating a MySQL Database for WordPress

Now, before installing WordPress we need a database where it would store its data and settings. MAMP ships with a database manager application called phpMyAdmin and the WordPress Codex has a guide on how to create a database with that, but let’s take a shortcut here and fire our Terminal in OS X. You can find it in your Applications folder or easier, through Spotlight.

Spotlight Terminal

The Terminal is a command line utility to your Mac, sort of what you might have heard about Linux, DOS and so on.

Terminal in OS X

If you’re planning to become a kick-ass WordPress developer, you’re going to have to learn this tool. We’ll type in a few commands (which you can easily copy and paste) that will connect to your local MySQL server, create a new database for WordPress and then create a new MySQL user with access to that database. Ready?

mysql -uroot -proot
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO wp@localhost IDENTIFIED BY 'hello';
EXIT;

Don’t get too scared yet, it’s quite simple if you understand what each command does. The first one connects to our local MySQL server using root as the username (the -u argument) and root as the password (the -p argument.) These are the default settings in MAMP. Note that there is no space character between arguments and their values. If that gives an error, you should explicitly tell Terminal where the MySQL binary is (where you installed MAMP,) in my case it’s:

/Applications/MAMP/Library/bin/mysql -uroot -proot

If everything’s correct, the first command will open a MySQL command line (in the same Terminal window) to which you type in the rest of the commands or as they’re called SQL queries. The first query (second command) is straightforward — it will create a new database called wordpress and the second query will grant all possible privileges (read, write, delete, etc.) on every table in the wordpress database, to the wp user originating from localhost identified by the hello password.

The third query exits the MySQL shell, at which point you no longer need Terminal so feel free to close it. Here’s a screenshot from my Terminal to make sure you’ve done everything right:

MySQL Terminal

As you might have guessed, the bolded words in the paragraphs above are the values we’re going to use when setting up WordPress, so we’re really close now!

Installing WordPress

Okay, I assume you already know where to get the latest version of WordPress. Download the ZIP archive and extract it to that document root directory. The one where we created our index.php file, remember? Note that the archive might (and probably will) extract an additional folder called wordpress with all the WordPress files inside. Feel free to move all the contents of that folder back to your document root and then delete the empty WordPress folder.

WordPress Contents in Finder

Now, open your browser and point your web browser to localhost again. This should bring up the WordPress welcome page and then on to your database settings, which you probably are familiar with already.

WordPress MAMP Database

The database name, username, password fields are the ones we used when creating the user and database, remember? The host field is localhost because MySQL is running on the same computer (your computer) as the Apache web server. The table prefix is up to you. I generally leave it wp_ for local installs.

The rest is pretty straightforward, blog name, admin username, password and e-mail. After having filled those in you’re left with your brand new and empty WordPress installation, on your local machine, running MAMP. Congratulations!

Conclusion

I’d like to end this tutorial with a few short tips you might find useful when working with WordPress locally on MAMP.

  • While MAMP itself is a lightweight application, when working for a long time without turning it off (and without restarting your computer,) it can get a little laggy and use too much memory. Kick it around from time to time.
  • If ever needed, Apache and PHP configuration files are located in MAMP’s conf directory, that’s /Applications/MAMP/conf.
  • Apache and PHP binaries and service scripts are available in MAMP’s bin directory, Apache, PHP and MySQL logs are in the logs folder (duh.)
  • You don’t need MAMP PRO unless you’re 100% sure you do.

Final tip — whenever you become a MAMP ninja, don’t stop there! Your next goal is being able to run a local virtual machine with your favorite Linux distribution linked to your Mac OS X with a network file system or something similar. That would really get you closer to the real world hosting environments, and a better WordPress pro.

Thank you so much for reading, hope you enjoyed it and feel free to ask questions, post comments and come say hi on Twitter too. Cheers and thanks again!

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.

6 comments

  • The first bullet point in the conclusion is so right. After awhile all the Apache processes being created and destroyed constantly will eat away at all your free memory and make your “inactive” memory pool larger than it needs to be.

    Definitely stop the servers processes when you don’t need them.

  • This -> Whenever you become a MAMP ninja, don’t stop there! Your next goal is to write the best tutorial available on the interwebs about how to run a local virtual machine with your favorite Linux distribution linked to your Mac OS X. :P

    • Oh hey Ivor, thanks for stopping by :) An Ubuntu Server with VirtualBox tutorial is in my roadmap already, so yes sir! I appreciate the comment, cheers!

    • Steve, honestly I haven’t tried DesktopServer yet, so I can’t really encourage people to use it. For the simplest matter, virtual hosts management is great and awesome, but I don’t want to use .dev domains, so I’d rather do it manually in my /etc/hosts file.

      Frankly, I’m not a big fan of MAMP, XAMPP, LAMP or whatever and I try to constantly push towards VPS, virtual environments and command line tools rather than all in one solutions. I think that one might greatly benefit from being able to work with the command line, install software, use source control, make database backups, configure schedules and so on. But the reason I mentioned MAMP is that it’s something in between which lets you use Apache and MySQL without having to install and configure Linux, which as I mentioned in a comment above, is a tutorial in my roadmap.

      Thanks for stopping by and keep up the good work with DesktopServer! :)