MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

Localhost WordPress on MAMP

with 19 comments

There’s so much energy that goes into blogging with big blog pages, I figured it was time to setup WordPress on my MacBook Pro MAMP (Mac, Apache, MySQL, and PHP) installation. That way, the world doesn’t need to know when I mess up a <div> tag.

The biggest benefit of creating a local blog becomes obvious when you start building your own plugins, templates, and themes. You also have the benefit of a built in backup if you post your work locally before moving it to your blog. Likewise, you can work on your blog when not connected to the network. By the way, thanks to Joel for pointing out that I forgot to say why this was important.

Here are the setup instructions for those interested in doing it too.

1. Download the software from WordPress.org by clicking their button or this one. If you need the tar.gz, click on the web site link.

wpdownload

2. When you download it, you’ll be prompted to open it. Choose to save it.

wpsavedmg

3. You’ll find it in your downloads folder, where you can double click it to launch the unzip process into a file folder. Mine happens on the desktop because it’s convenient.

wpunzip

4. After you’ve unzipped it into a folder. You drag it into your MAMP htdocs folder. You can check where the htdocs folder is by launching the MAMP application, and choosing Preferences.

mampprefs

In the preferences dialog, click the Apache tab, you’ll see where the htdocs folder location is. Mine is set to the default location.

mampapache

5. After you drag the wordpress folder into the htdocs folder, you return to the MAMP application and click the Open start page button.

mamphomemenu

6. Click the phpMyAdmin link and create a database, like the screen shot.

mysqlcreatedbms

After a moment, you should see that you’ve created a new database named WordPress.

mysqlcreateddb

7. Go to your /Applications/MAMP/htdocs/wordpress folder, and open up wp-config-sample.php file in a text editor. You should see the same lines 19, 22, and 25. The editor screen capture is from the TextMate editor.

wordpress-config

Edit those lines to reflect your database name, and the root password. Naturally, if you’re concerned that your local host isn’t secure, you’ll need to purchase MAMP Pro to change your root password. You can’t change it in the free version.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'WordPress');
 
/** MySQL database username */
define('DB_USER', 'root');
 
/** MySQL database password */
define('DB_PASSWORD', 'root');

After these changes, save the wp-config-sample.php file as wp-config.php in the same folder.

8. Enter the following in URL in your browser, and press the enter key.

http://localhost:8888/wordpress/wp-admin/install.php

9. On the Welcome web page, enter your blog name and email (mine is omitted for obvious reasons). Click the Install WordPress button to proceed.

wpinstall

10. You’ll then be prompted with the admin user and a password. You should print it or copy it to your buffer because you’ll need it when you first login. Then, click the Log In button to proceed. You should probably change your password to something that you’ll remember before you do anything else.

11. You now have a complete localhost WordPress installation. Now, you can go to your real web accessible WordPress install and export your blog from the Tools menu. Then, on your localhost blog, you can import from the export file of your blog. If you’re using plugins (like anybody doesn’t), then copy the contents from the wp-content/plugins folder from your online blog to your local one; and then, activate them. You can snag your Akismet key from your online site too, but it is unlikely anybody will see your localhost blog.

ViolĂ , c’est fine.

You can now access WordPress on your local machine by typing in the following URL:

http://localhost:8888/wordpress/

Written by maclochlainn

February 22nd, 2009 at 1:30 am

Posted in Mac,MAMP,MySQL,WordPress

19 Responses to 'Localhost WordPress on MAMP'

Subscribe to comments with RSS or TrackBack to 'Localhost WordPress on MAMP'.

  1. Ok, I guess I’m confused.
    Why would you ever do this?
    Whats the point or having your blog local?
    (Obviously, I’m missing something here)

    Joel

    23 Feb 09 at 9:38 am

  2. Joel,

    The biggest benefit comes when you start building your own plugins, templates, and themes. If you fat finger something, you’re only recovering a local copy of your blog. You can also work on your blog when not connected to the network.

    maclochlainn

    23 Feb 09 at 12:32 pm

  3. AH! OK, that makes sense to me.
    I was thinking “Wow, how could this possibly help you post to your blog and there are definitely better tools than this!”
    But I can see that as a way of working with the more technical aspects of the blog
    thanks!

    Joel

    23 Feb 09 at 12:45 pm

  4. I appreciate you letting me know because there wasn’t any why in the post. I’ve fixed that thanks to your comment. :-)

    maclochlainn

    24 Feb 09 at 12:18 am

  5. Then my work here is done ;)
    (I’m also mucking around with php a smidge, so this might end up being pretty useful)

    Joel

    24 Feb 09 at 7:43 am

  6. Thanks for the great step by step instructions.

    dan

    3 Mar 09 at 9:36 pm

  7. I am developing a WordPress site on a Mamp installation. How do I go live with this when I am done? If I am using plugins with content, say a quote generator, will data that I entered into the plugin be exported into the live installation?

    Thanks!

    Susan

    28 May 09 at 8:42 am

  8. Just install the same plug-ins that you have on your local machine and do an import. The only problem will be the image files, which you’ll have to move over to the new site.

    maclochlainn

    28 May 09 at 8:17 pm

  9. Thanks for a great tutorial how to do this. I have a question. I did all of this and for some reason my photos aren’t showing up in the “themes” index.php or even the admin little clipart or pretty much any picture. Login and everything works, makes it kinda hard to make changes when I can’t see much. Is it a .css problem?

    Deborah

    2 Sep 09 at 8:13 pm

  10. The export only takes the text. You must manually move the images. Open one of your posts and you should see that the image is found on the original WordPress site. Unfortunately, there’s no easy way to move those images. At least, I don’t know of one.

    maclochlainn

    2 Sep 09 at 8:39 pm

  11. I’m a little late to the party, but I need some help. Hope someone is still around. I followed your instructions and got it to work. Only problem is the templates don’t show up. I activate them and the path is right but the page is white. This happens to template I place in the theme folder and to the default templates. Has anyone ever heard of this problem? If so, is there a fix? Thanks so much.

    Stephen

    6 Sep 09 at 10:44 pm

  12. Stephen, You can check Step #2 in this older post for the template stub, or go here. If you need more help, post another comment.

    maclochlainn

    7 Sep 09 at 10:00 pm

  13. I’m just now getting back to this from sept. 2. What I meant in my previous post was that the pictures/background art doesn’t show up locally, even the wordpress icons. No matter which theme I choose, they don’t show up but the text is formatted. Any ideas? Oh, also to get mine to show up my path is : http://localhost/wordpress/ (a bit different from your example)

    Deborah

    19 Sep 09 at 11:59 am

  14. UPDATE: I figured it out. I read that wp needs to be installed into the “htdocs” folder inside of MAMP, inside of the apps folder. I also changed my Preferences inside of MAMP to “Reset MAMP ports” and it changed the Apache Port to 80 and they MySQL Port to 3306 and in my browser I put in “http://localhost/wordpress” and everything works perfect. I am new at this so don’t know if it’s the right way but it works to work locally.

    Deborah

    20 Sep 09 at 11:34 pm

  15. So, clearly, after I did the install (I’m computer literate, but not blog literate…yet.) the final instruction (11) got me. Real web accessible WordPress install? Localhost blog? Export file? All of sudden, at the very end, it seems that I’m going to need a book or instructor to build a blog with WordPress on my Mac, rather than the virtual plug and play of the (not working) blogspot account I set up yesterday. Are there any ways to make it easy like Blogspot but not have to spend hours becoming a blog-programmer? Thanks.

    Jeffe Aronson

    15 Jan 10 at 1:45 pm

  16. I’ll try to put something together for you later this weekend. Thanks for the note.

    maclochlainn

    16 Jan 10 at 12:10 pm

  17. That was fast and easy! Thank you for making that simple and straightforward! Much appreciated.

    Tom Marsh

    15 Feb 10 at 1:24 pm

  18. Hi!

    I installed MAMP and Pro Sequel as database on my Mac. Managed to to all the steps above and install wordpress. But when I am in wordpress dashboard and want to see how my website would look like in a browser, my browser only displays dir of files in …./htdoc folder.

    How can I fix it?

    Alice

    24 Jun 11 at 12:42 pm

  19. I think the URL probably starts with file///. If so, try this:

    http://localhost:8888/wordpress/

    maclochlainn

    24 Jun 11 at 2:19 pm

Leave a Reply