Setup WordPress Locally On Mac OS X

When designing WordPress themes, it’s nice to be able to store them locally to test them instead of uploading files to a web server (though Transmit makes it quite easy). In this tutorial, you’ll learn how to set up WordPress locally on your Mac and then manage multiple blogs with their own themes.

The first thing you’ll need to do is make sure you have MAMP installed and running on your Mac. If you don’t, follow this tutorial first, and come back here when you’re done.

Next, you’ll need to have the latest version of WordPress.

After MAMP is up and running, drop that latest version of WordPress into the folder that your sites are stored in. For example, the htdocs folder in the MAMP Applications folder (default), or the folder you specified, such as Users/Username/Sites.

Next, we need to create a database so we can run WordPress. Open up the MAMP Startup page (there is a button on the control panel window), and go to phpMyAdmin.

In the MySQL column, there is a table for creating a new database.

After your database is created, open up the ‘wp-config-sample.php’ file in the root WordPress folder. Change the database name to ‘wordpress’ (or whatever you called your database). Both the username and password are ‘root’, and the host is localhost.

define('DB_NAME', 'wordpress'); // The name of the database
define('DB_USER', 'root'); // Your MySQL username
define('DB_PASSWORD', 'root'); // ...and password
define('DB_HOST', 'localhost');

Save this file as a new file with the name wp-config.php.

To install WordPress, open up wp-admin/install.php. From there, it’s the standard, simple WordPress installation.

Once installation is finished, you can view your blog at http://localhost:8888/WordPress/. Of course, the Dashboard is located at wp-admin/.

If you want to run multiple blogs with their own themes, all you have to do is repeat this process, and give each database a new name. You can use the same database if you like - some people prefer to have certain sample posts to test things.

3 Responses to “Setup WordPress Locally On Mac OS X”

Chris Thomson
Posted on January 30th, 2008 at 9:21 pm

It’s always fun to test the latest WP nightly build locally, and SVN also works on OS X! Here’s a quick little tutorial on how to do that:

* Open up the Terminal (Apps -> Utilities -> Terminal).
* Then you’ll want to navigate the terminal to the directory WP is installed in. Here’s how. Let’s say you want your WP install to be in /Users/YourUserName/Sites/WP/ … you’d type:

cd ~/Sites/WP

Then, you’ll need to install the latest ‘bleeding-edge’ version, using SVN:

svn co http://svn.automattic.com/wordpress/trunk/

The terminal will list lots of files (WP files), as the terminal is pulling all of the WP files to your system.

From there on, just navigate to that folder using localhost:8888/WP (your local address, and folder WP is in), and install it as described above! To update WP from there on (it’s updated daily), type:

svn update

… once you are in the terminal, and have navigated to the WP directory using the CD command.

You might also want to refer to this article on the WP Codex on how to use SVN.

I hope this helps!

Greg L.
Posted on February 3rd, 2008 at 4:52 am

Great link and article. I’ve been meaning to setup something like this on my machine for ages, but have procrastinated like crazy. MAMP made it so ridiculously easy, though. I was up and running Wordpress and all my other applications within 5 minutes.

*waves goodbye to frivolous ftp access*

Matt
Posted on February 24th, 2008 at 11:13 pm

Thanks for the easy to follow tutorial, I was up and running in a matter of minutes.

Leave a Reply