How to install WordPress locally on a Mac


Developing in a local environment can be a real asset when you’re developing for the web. Not only will developing locally be faster than waiting for file uploads via FTP, testing new features on your local machine will always be safer than testing them live.

Setting up a local WordPress installation isn’t difficult, but it can be a bit tricky if you haven’t done it before. This tutorial is designed to walk you through the process from start to finish. I’ve also included an optional step for those interested in running WordPress Multisite locally, though those interested in a standard WordPress installation can easily skip over them.

So you know, these are the steps we’re going to be taking to install WordPress locally on a Mac:

  1. Download and install MAMP
  2. Edit your hosts file (optional)
  3. Load WordPress files into your new /htdocs folder
  4. Edit your wp-config.php file
  5. Load up your editor of choice and enjoy local development!

Enough prep, let’s get started!

Step 1: Download and install MAMP

In order to run WordPress, we need to have MySQL and PHP running on our Mac. A simple way to do this is an app called MAMP, which stands for “Mac, Apache, MySQL, PHP” and sets up a local environment on your Mac.

MAMP can be download here, and installing it is just as straightforward as installing any other application.

Once it’s running it will open up the MAMP start page, which will double as confirmation that it was installed correctly as well as quick links to phpMyAdmin and other database information. Here you will see that the database username and password is, by default root and root. You can change this if you want, but as far as I know there is no point to doing so.

One suggestion I do have is to go into the MAMP Preferences panel (seen to the right) and select “Set to default Apache and MySQL ports” to set the Apache port to 80 and the MySQL port to 3306. It should match the settings of the screenshot on the right.

With MAMP fully configured, visit phpMyAdmin from your MAMP start page and create a new database for your WordPress installation. Keep the database name in mind.

Step 1.5: Edit your hosts file (optional)

This is an optional step, though it is necessary for running WordPress Multisite.

If you don’t understand what is is, see our introduction to Multisite.

WordPress Multisite cannot operate with a port number in the URL (http://localhost:80/ for instance) so we want to map a new URL to our localhost address. To do this, first open up Terminal (don’t worry, it’s not too scary!).

In order to map a new URL to localhost, first enter:

sudo nano /private/etc/hosts

This will bring you to your hosts file within Terminal. You may need to enter your admin password to access it.

Once you have access to the hosts file, navigate down to the bottom of the list and add the following line, with a tab separating them:

Note that the URL you enter (in my case, can be anything you want. I would recommend choosing something short and memorable.

To save the hosts file, press Control + O and hit enter. This will save your hosts file, and you can close Terminal. You will know if it works if you visit the URL you chose and it brings you to your MAMP files.

Step 2: Load WordPress files into your new /htdocs folder

We’re now ready to install WordPress, which I’m sure you are familiar with. Download WordPress and move the files into your /htdocs file, which will be located within the MAMP directory in your Applications folder.

At this point you have the option to either create a subfolder for your WordPress installation or to add it directly into the root. In this case we’re doing it at the root, though you are free to do what you want.

At this point it wouldn’t be a bad idea to also rename your wp-config-sample.php file to wp-config.php. We’re going to be editing that in the next step.

Step 3: Edit your wp-config.php file

Now we will add the Assuming you didn’t change the root username and password, use root for each along with the name of the database you created back in Step 1. I called my database wpdev, so my file looks like this:

Save this file and visit the home directory to complete the installation process.

Step 4: Load up your editor of choice and enjoy local development!

If everything above went smoothly, you should now be looking at a solid local copy of WordPress, primed and ready for testing and development. Crack open Textmate, or Coda, or your application of choice, and have some fun.

Are you using WordPress locally? What do you use it for, and how has it helped you in your work?

59 thoughts on “How to install WordPress locally on a Mac

  1. I have the latest version on MAMP and I didn’t have to do Step 1.5 to make it work without a port in the URL. The URL is just http://localhost and has no port attached to it. Worked for me in both Chrome and Safari.

    Although I did do it so I could give it a different name than localhost.

    Nice tip!

  2. Great post! Is there a any good tutorials that involve transferring it from a local mac to a live site? Basically, the next steps beyond this.

  3. Pingback: Review: Shelf Theme from The Theme Foundry | WPCandy

  4. Pingback: Setup WordPress Locally On Mac OS X | WPCandy

  5. Hi, great post !
    Can you please clarify the last substep of Step 1, where you mention creating a new database. I go to the SQLiteManager tab of the MAMP page that opens in the browser, it asks me the following questions:
    – Name: this one is easy enough 🙂
    – Version: 2 or 3 (?)
    – a blank field immediately below with a “Browse” button next to it (?)
    – Path: with a “Upload Database” checkbox and again a field with no label below.
    Can you please advise on this? Sorry not a techie here…
    Thanks !

  6. hi!
    i have installed wp in mamp now, but i don’t get step 4.
    What i wanted to do with this program is using downloadable themes for my wp blog. can anyone explain me how to do that? (step by step?)
    thanks a lot!

  7. Hi, first time Mac user here. Do I need to install both MAMP PRO and MAMP? And how does MAMP compare to XAMPP? Can anyone enlighten me? Thanks!

    • I’m honestly not sure about MAMP compared to XAMPP, but I can tell you that you only need to install MAMP. Well, either MAMP or MAMP PRO. PRO is just the paid version of MAMP. I prefer to use the free version, but it’s up to you.

      Good luck!

  8. After looking at a few other tutorials, I was getting the dreaded “got packets out of order” error. I’m NOT a programmer. I was dumbfounded as I didn’t find anything helpful online…until I found this tutorial. I don’t know if it was the different port numbers or the root shortcut in Terminal, but whatever it was, THANK YOU!!!!!

  9. Thanks for sharing this! I have a question, though.

    I’ve gotten as far as shifting all the files to the htdocs folder, but they still open in text edit instead of running the install. What did I do wrong?

    • Hmm, sounds like you might not have MAMP running. Is it? Visiting the folder your WordPress install is in should prompt you to install if it’s running.

      • MAMP is running, but it just does not seem to be translating the PHP. There also seems to be two PHP settings on MAMP – does it matter which one is selected?

        • I’m having the exact same problem!
          Not sure what do to next!
          MAMP is running but, installation isn’t starting…
          what do i do?

          • I’m having the same problem. I’m a PC user who recently switched to a Mac. I am confident that one day I will understand how it works, but these types of problems make me miss my PC.

  10. So, I tried to set the defaults for MySQL & Apache, but then mamp refused to start the servers. So I reverted back to 8888 and 8889, and the servers started, but for some reason, when I go to or to http://localhost/, it simply says in bold, black letters, “it works!” but it doesn’t give me access to anything.

    I can actually hear my computer laughing at me. . .

  11. Hey Ryan,

    Great Tutorial!

    Can you tell me the best way to set up multiple instances of WP to develop multiple sites? Is it as simple as setting up a directory structure like:
    WIth a WP install in each?

    Then accessing the site with localhost/site1?

    Thank you in advance!


  12. Hi there

    Im afraid I got completely lost at satge 3…sorry but can you explain in more detail how to do this?

  13. Thanks for this writeup… I’ve followed all the steps (except the optional one) up until the end of step 3 where I’m supposed to “visit the directory”. I’m not sure what that means, what application to do it with (MAMP?- I don’t see how to do this?). I wanted to install WP locally to mess around with other themes– is there a way to edit my local version of WP through the dashboard interface, and see the changes??
    thanks a lot,

  14. Hope someone can help.

    I’ve installed and everything runs fine. Mu only issue is when activating plugins or writing a post the screen goes blank but when I login again the plugin or post has been created.


  15. I got lost at the end of “Step 3” where it says:
    “Save this file and visit the home directory to complete the installation process.”
    Can someone explain this sentence more clearly?


  16. I too am struggling with ” Step 3 “. Can anyone offer some advice as to how to proceed to the ” Home Directory ” and complete the installation process ?.


      • Thanks for the reply, unfortunately I had tried accessing the site ‘http://localhost:8888/ in various browsers and it just says that the site cannot be found, in Safari I also get a message saying PHP not installed or running on the web server. I can’t seem to find any more info to check this out as I have php set on my MAMP preferences.

      • it should be ‘http://localhost:80/’ if you followed the authors suggestion of ‘Set to default Apache and MySQL ports’

  17. I want to change the theme of my WP site. This is not a simple switch, but a completely different theme set up, with completely different ways that the pages and blog will operate from the theme I have now. I want the current theme to be live while I work on the new site. I’m not a programmer and before creating my blog last year had always had an html site which I created locally with Dreamweaver on my computer, and uploaded to the server via ftp. What I’m wondering is can I use your method of installing WP on my Mac to create the site with the new theme, then, when it is complete, upload it to my Hostgater home directory in place of what is there now? Thanks for your help.

  18. This is a great tutorial for ppl who use a mac. However, I would like to do this on my local pc in Windows using WAMP (I can’t afford a mac yet). What I would like to do is have a separate folder in www for each site, so I can do as many sites as I need to do. Can you tell me how to do this and make it work? I’ve been trying it on my own, but once I put wordpress into a folder in www, it doesn’t want to work. Am I missing something?

    Thanks in advance!

  19. Huge help – I’m not a developer and this was the best tutorial I’ve seen. Including screenshots makes all the difference. Keep up the great work Ryan!

  20. hahahaha yes this is so darn cool! now i can really get some working going on with my web design project. Hey what route do i have to take to get buddypress on here? Do i just treat it like a regular online site /ftp directory…/

  21. I got as far as: “With MAMP fully configured, visit phpMyAdmin from your MAMP start page and create a new database for your WordPress installation.” There’s no diagram and I couldn’t find that page or any indication of phpMyAdmin anywhere. Please help ASAP as I am sitting here trying to get past this. TY

    • If the “start page” you refer to is the “Welcome to MAMP” website page, I found that behind my open windows. I am unable to click on the “phpMyAdmin” link tho, nothing comes up. This is all too confusing for me…please HELP.

  22. Step 4: Load up your editor of choice and enjoy local development! If everything above went smoothly, you should not be looking …
    Shouldn’t this read “now be looking”? The one letter makes a very big difference.

  23. You are welcome. Now to the problem. You say, “load your editor of choice”. Isn’t the editor WordPress? Wasn’t the idea to install WordPress on my local drive? After downloading MAMP and jumping all the hoops to install it and WordPress into the MAMP folder, I can’t seem to open, or even find, an application called WordPress on my computer. I recently downloaded (bought) a theme called The Furniture Store ( which is a very well organized theme. I design furniture and am setting up the business. Just setting up WordPress to utilize this theme has been a maze of hoops to jump through – and I haven’t seen the light at the end of the maze. Am I missing something? All the text on the web says installing WordPress is easy.

  24. apache server works but mysql doesn’t. Tried various ports but still getting errors logging in. Any help will be appreciated.

  25. Step 1 says…”With MAMP fully configured, visit phpMyAdmin from your MAMP start page and create a new database for your WordPress installation. Keep the database name in mind.”

    If I have setup a database for my site remotely on hostgator can i select that database? Or do I need to make a new one locally?


  26. Thanks so much for this tutorial. It worked like a charm on my Mac. I have one question, what is the best way to get the finished WP product from your local host to your server? Are there any pitfalls to be aware of? I was thinking to just copy the local WP folder to my 1and1 server, change the WP Config file to use the database info generated from 1 and 1, and then follow the WP Install as normal… Does this sound right?

    Thanks in advance for your comments

    • I am wondering the same as Randy. Someone told me that the images would not work if I did it that way. What is the proper routine then for designing a site locally and uploading it easily? Thanks.

  27. I’ve been trying and trying to do this for HOURS!!!!!!!!!!

    I don’t know what to do any more I’ve downloaded and uninstalled MAMP and then downloaded again when I came to this site but I get as far as changing Port codes.. My status is red on both the Apache Server and MySQL Sever??? I am connected to the internet but I have no idea where to go from there??? There’s no where to open a new page?? I’m so frustrated 🙁

    I just paid $50 for a site that I’m meant to upload to wordpress and now I cant use it 🙁

  28. OK, I followed the instructions here and have gotten farther than with any other tutorial but…..

    I type “http://localhost” and I get an index of the folders/files in the MAMP folder (is this correct?). If I select the “htdocs” folder the URL changes to “http://localhost:8888/htdocs” along with the following message:

    Safari can’t connect to the server.
    Safari can’t open the page “http://localhost:8888/htdocs/” because Safari can’t connect to the server “localhost”.

    You state go to the home directory to complete the installation process, what does that involve? I have never seen the WordPress setup page. Ryan are you still answering questions on this subject?

      • ansel,

        Thanks for your reply but I figured things out a few hours after I sent that comment (wow almost a year ago). It was so long ago I can’t even tell you what the solution was… lol!

        Again thanks for replying.


  29. Im not sure exactly what else to do.
    If you could assist me or anyone on the chat It would be a blessing.

    I think I accidentally changed my default settings of Apache under the preferences to (/Applications/MAMP/htdocs) … Im not sure if that is the problem or something else.

    I cant get the process and complete download to work.

    The last step of logging into my wordpress back office doesnt display when I type in the URL.
    Please assist.
    I have been trying to figure this simple issue out all day.
    Best Regards.

    • Jason,

      I just got the email that you are/were having a problem (yikes over two months later). If you have not figures things out let me/us know.



Comments are closed.