How to Set Up a Local WordPress Installation on Your Mac

How to Set Up a Local WordPress Installation on Your Mac

Do you love unnecessary hassle when working with WordPress? Relish grinding through theme or plugin development at a snail’s pace? Does your heart skip a joyful beat at the prospect of losing a client by bringing down a live site for totally avoidable reasons? Then this article may not be for you.

If, on the other hand, you’re looking to simplify your working life and take control of your day-to-day WordPress development, keep reading.

We’re going to cover one of the simplest steps you can take to streamline and professionalize your workflow: setting up a local WordPress installation on your Mac.

Before we get into detail though, let’s quickly recap the main reasons why you should do this.

Why You Need a Local WordPress Installation on Your Mac

Here are four solid reasons that will have you wondering why you didn’t do this sooner:

1. You Will Enjoy the Freedom to Work Offline

We’re moving closer and closer to a truly always-on digital world, but the day where you can take an ever-reliable and uber-speedy internet connection for granted is still some time away. Unexpected travel, intermittent network coverage and remote outages are just three reasons your carefully laid plans may be unexpectedly derailed.

Having a local install available means you’re free to work how, when and where you want. That’s invaluable.

2. You Will Be Faster Across the Board

No matter how beefy your server is, reading direct from the local disk is always going to be quicker. All those remote database calls and page loads add up quickly. By working on a local machine, you’re potentially shaving hours of wasted time off your working week.

You also stand to gain from a general knock-on effect on productivity. The type of unexpected, unpredictable delays you inevitably experience working on a remote setup are an absolute killer for productivity and flow.

Get your local setup dialled in on the Mac and you’ll be working faster and more efficiently across all areas of WordPress in a matter of hours.

3. You Can Test Ideas More Quickly

WordPress is an incredible playground for designers, developers, marketers and business owners, but the gap between idea and execution can sometimes be large.

Regardless of your background, the ability to move from idea to prototype in a risk-free, local environment in a matter of minutes will change your creative game.

4. You Won’t Risk Breaking the Live Site

Let’s say it straight: doing serious development work directly on a live site – or making substantial changes without testing their impact locally first – is a trademark cowboy coder move. You need to stop doing it.

Whether you’re looking at specific site changes, or developing plugins or themes that will be deployed on many sites, a local installation gives you a stable, safe working environment to test and refine your work before you deploy anywhere critical.

Hopefully by now you’re convinced of the need for a local install. Now let’s start making your life simpler.

Creating a Local Environment with MAMP

Mamp

There was a time when getting a WordPress-friendly local development environment working was an arduous job reserved for masochists, command line wizards, or both.

These days, fortunately, it’s a relatively straightforward task, and the basic setup is beginning to rival the speed of WordPress’ own famous 5-Minute Install.

We’ll give pointers for more advanced setups at the end of the article, but by far the simplest way to get started quickly is by using MAMP – an application specifically designed to give you all the ingredients of a local server on your Mac.

WordPress needs two basic things to run:

  • a web server running PHP, and

  • a database.

MAMP – short for Macintosh, Apache, MySQL and PHP – gives you all of this straight out of the box in one easy to install, downloadable package. Let’s get started.

Download and Install MAMP

Head on over to the MAMP website and download the standard free MAMP package. There’s also a premium version available in MAMP PRO, but the standard version is more than adequate for your initial needs and contains everything necessary for running WordPress locally.

Once the package has downloaded, simply double-click on the MAMP disk image, drag the MAMP folder to your Applications folder and proceed as normally from there.

If you find yourself getting stuck at any stage, consult the excellent installation overview on the MAMP site.

You’re now free to start MAMP by launching MAMP.app, which should be located in /Applications/MAMP/MAMP.app.

Configure MAMP Settings for WordPress

MAMP Port Settings

After you’ve launched MAMP, there’s a little bit of prep work to be done prior to installing WordPress. Begin with ports. Click on Preferences, select Ports and then select Set Apache & MySQL ports to 80 & 3306. These are standard port settings for these services that you’ll also see on remote servers, so it’s a good idea to use them here.

MAMP ports preferences screen

Now set your Document Root. This is where your web files reside on your computer and what Apache uses to serve them. By default this will be located in the MAMP Application directory at /Applications/MAMP/htdocs, but you’re free to change it to wherever is most convenient for you. A local Dropbox folder, for example.

MAMP Apache preferences screen

At this point, fingers crossed, everything should be working smoothly. Check back on the MAMP launch screen and check if services are running by looking for small green squares at the top right of the screen. If they are not running, hit Start Servers.

Now click Open start page and you should be looking at a version of the screen below.

MAMP Success Page

This is a local web page giving basic information about MAMP and its components. It’s being served directly from your hard drive by Apache.

Gotchas

If you run into difficulties along the way, start with the MAMP documentation. Failing that, remember that Google and Stack Overflow are your friends. Two common gotchas to beware of are Apache or MySQL not starting.

Setting Up Your Database

Now let’s create our first database. MAMP comes with phpMyAdmin (a convenient and powerful tool for managing MySQL databases) installed as standard, so we’ll be using that.

You’ll also find phpMyAdmin installed as standard on many remote hosting environments, so getting used to working with it locally is a great way to brush up your skills in a safe setting.

We need to do two things:

  • create a database for our WordPress install to use, and

  • create a user for that database with the appropriate privileges.

Begin by opening up the Tools menu on the MAMP welcome page and launching phpMyAdmin. Now click on the Databases tab, enter the name of your database in the Create database field and click Create. Use a UTF-8 collation such as utf8_unicode_ci to avoid issues with character encoding down the line.

Create database in phpMyAdmin

Now navigate to the Users tab, click Add user, enter a name and secure password and set the host to local. Then return to the Users tab, select Edit privileges on the user you just created, click Check all and save. We’re assuming here that this database will only be used locally and by yourself.

Make a note of the database name along with the user name and password. You’ll be entering them again shortly.

Create a user in phpMyAdmin

If you run into difficulties at this stage, head on over to the WordPress guide to using phpMyAdmin and troubleshoot from there.

Install WordPress

WordPress

The stage is now set and you’re free to move on to more familiar ground by installing WordPress itself. The process here is essentially the same as installing on a live server; the server just happens to be located on your machine.

Begin by downloading the latest version of WordPress and extracting it to a named folder in the Document Root you defined earlier. Let’s assume in this instance you call the folder my-wordpress.

Make sure MAMP is running Apache and MySQL and navigate via browser to the WordPress install script in that folder. Use the address format localhost:port/folder_renamed/wp-login.php. In our example that would be localhost:80/my-wordpress/wp-login.php.

Navigating to there should kick you into the familiar WordPress 5-Minute Install sequence. Complete this using the database details you created previously and you are now free to develop locally at your leisure.

Taking Your Local WordPress Install to the Next Level

Congratulations! You are now covered for basic local development in WordPress. At some stage though, you’re going to be looking to spread your wings a little in terms of the complexity and sophistication of your setup. Here are three more advanced topics to explore when you’re ready to take your local WordPress environment to the next level:

1. Desktop Server

Desktop Server is a tool for automating and managing many of the steps we’ve just taken across multiple local installs. It can also be used to sync these local sites with live environments. Free and premium versions are available.

2. Varying Vagrant Vagrants

Not for the faint-hearted, Varying Vagrant Vagrants is a sophisticated approach that leverages the power of virtual machines in Vagrant to create programatically reproducible WordPress development environments. There’s a great intro to the concept over at WebDevStudios.

3. Exploring Development Workflow

We’ve concentrated on the local environment here, but more sophisticated setups will call for a full local -> staging -> production workflow. This is a vast topic, but you can start dipping a toe in the water with WordPress Tavern’s overview.

Conclusion

Whether you’re a developer, designer or site owner, getting WordPress set up locally is going to save you a huge amount of time and a lot of sleepless nights. And, as we’ve hopefully shown, it’s not that difficult to do. Here are the basic steps again just to recap:

  • Download and install MAMP,

  • Set up your database and database user with phpMyAdmin, and

  • Install WordPress locally and get to work!

Once you have the basics set up, a world of further optimization options will open up for you. Let us know where you take it in the comments below and feel free to share this tutorial with others who you think might find it useful!

By |2018-08-31T14:58:17+00:00April 8th, 2015|Tutorial|

63 Comments

  1. Francesco April 9, 2015 at 10:24 pm

    Hi. I find this article extremely useful. By the way, I cannot see the images. It’s only me? Or They are not uploaded?

    • Luke April 9, 2015 at 10:33 pm

      Thanks for the comment! Images will be back shortly, minor technical difficulty!

    • Tom Ewer April 10, 2015 at 11:06 am

      I’m glad you like the article Francesco, and the images seem to be back up now 🙂

  2. Anthony April 11, 2015 at 3:05 pm

    I’m really interested in this and i just bought your theme. My question is how does the local install go live on the web server? If this setup works i’m going to save HOURS. I remember trying to do this years ago and it was a nightmare. How does the local database and images etc.. upload to the live environment?

    • Tom Ewer April 13, 2015 at 11:36 am

      If you bear with us a week or two Anthony, we will have your question answered in full with a standalone post 🙂

      • weishida March 27, 2016 at 10:09 pm

        Did you ever write a post on how to upload changes from local to web server? Are there any other apps that you’d recommend now since this article was written? (Mac) Thanks

        • Tom Ewer March 29, 2016 at 7:54 am

          We did! You can find it right here!

          As for software, we still recommend everything offered up in the article – they’ve been used for years by thousands of developers, so you know you’re in good hands 🙂

  3. Dr. Lawrence Kindo April 12, 2015 at 2:19 am

    Nice tutorial by the way!

    Just tried installing MAMP 3.2 but the install stalls and stops midway. Tried a number of times but still fails. Should I use MAMP 2.2 instead?

    • Tom Ewer April 13, 2015 at 11:36 am

      I’m not entirely sure Lawrence; it’s impossible to say what might be going wrong I’m afraid.

  4. oaklandum April 15, 2015 at 3:35 pm

    Hi Tom – I’m in the same boat as Anthony. I’m just getting started (yesterday) with Avada (awesome!!) and am new to moving/uploading sites. I look forward to the upcoming post on sending a local theme live, but in the meantime, here is my question: Should I build my site out on a subdomain (currently doing), or should I stop and start fresh with a local install? I agree that all of the loading wastes a lot of time, but I’m concerned about being able to move a local install online. Thanks!

    • Tom Ewer April 16, 2015 at 9:33 am

      To be honest, I can’t answer that question for you. Theoretically, building on a subdomain reduces the likelihood of teething issues when migrating, but on the flip-side, running a site offline can save you a lot of time. It’s up to you I’m afraid!

      • oaklandum April 16, 2015 at 2:17 pm

        I appreciate the response. I am blown away by Avada – hard to focus on my day job with all of the excitement!

        • Luke April 16, 2015 at 2:44 pm

          Happy to hear that! Thanks for the comments 🙂

  5. JoeyG April 27, 2015 at 4:09 pm

    Hey Guys. I’m stuck at the last step. 🙂
    Not sure exactly where “extracting it to a named folder in the Document Root you defined earlier” is.
    Where exactly should I be extracting WP?
    Is it in the htdocs folder or?

  6. Tom Ewer May 8, 2015 at 8:56 am

    Hey Joey,

    Sorry that the tutorial isn’t quite clear enough 🙂

    When installing WordPress you create a folder within the Document Root, which is htdocs by default. So, you would create a /my-site/ folder within htdocs, then add the WordPress files to that folder.

    Hope that makes sense!

    Cheers,

    Tom

  7. Anna July 8, 2015 at 6:59 pm

    This was very helpful! Thanks so much!

  8. Thanks for the article. I just now installed wordpress on my mac locally.

  9. Tej Kahlon July 29, 2015 at 4:01 pm
  10. Magnus Andersson August 8, 2015 at 9:05 am

    Thank you so much for this guide. I tried this some years ago and gave up. You made my day – and many days to come 🙂

    • Luke August 9, 2015 at 10:18 pm

      You’re most welcome 🙂

  11. n lapeña jr September 1, 2015 at 7:39 am

    Thanks a lot! Was able to install WordPress locally. I don’t have a website nor a developer. Just trying to learn this stuff.

  12. zaithe November 16, 2015 at 7:03 pm

    Thanks, worked great!

  13. David January 23, 2016 at 5:02 pm

    Thanks Tom! The article is really clear

  14. laurafig January 25, 2016 at 3:20 pm

    I successfully installed MAMP and WordPress and had no trouble installing themes until I purchased Avada. Every time I try to install I get the message “Are you sure you want to do this? Please try again.” In the Avada documentation it mentioned something about “provider size limit” and suggests installing via FTP. Since I’m installed on the local host how does this advice apply?

    • Luke January 25, 2016 at 3:24 pm

      Hello!

      Actually the same rules apply to a local install as well. Check your wp-config file, it probably has low values. You can also just upload the theme folder in the folder structure (wp-content > themes). for further help with Avada, submit a ticket to our team here: http://theme-fusion.com/support-ticket/

      • laurafig January 25, 2016 at 4:17 pm

        Thanks so much Luke! Very simple solution to an apparently common problem.

        • Luke January 25, 2016 at 4:40 pm

          You are welcome 🙂 Yeah very common problem and I wish the error message “are you sure …” would be more clear to the user with additional details.

  15. Adam Lee Rosenfeld February 10, 2016 at 2:08 pm

    Thanks for the helpful information, Tom! Always a pleasure to learn something new from you.

    • Tom Ewer February 13, 2016 at 7:53 pm

      Thank you for reading my articles, Adam! I’m glad they’re helpful to you.

  16. Anita February 24, 2016 at 6:21 pm

    Excellent instructions! Thank you so much for this page, Tom.

  17. TA February 24, 2016 at 9:04 pm

    Thanks a lot for this great explanation. It won’t be able though for me to do the wordpress-installation since it keeps telling me that there is a problem with the database-connection. I also tried to confugire the wp-config.php myself, but how would I execute it? When I do it via the form then, it says that a wp-config.php already exists?!

    Maybe somebody can help?

    Thanks.

  18. Don February 25, 2016 at 12:30 am

    I cant connect to local host?

    I set up a folder on Box.

     

    http:80//localhost/myfoldername/wp-login.php

     

  19. Don February 25, 2016 at 12:42 am

    I read the note above so I have created:

    • site_folder_name

    • htcdocs folder. (what does htc mean?)

    • I pointed MAMP to site_folder_name

    • Created a new database

    • Used

    localhost:port/folder_renamed/wp-login.php

    Is it because I’m on Box?

  20. Xus March 3, 2016 at 4:34 pm

    Thank you, Thank you, Thank you.. after almost 3 hours trying to install a wordpress locally… it only took me 5 minutes following the steps of your post..

  21. Luis March 9, 2016 at 5:41 pm

    Damn – that was the best explanation on how to set up my local WP environment. Thanks, guys, for posting this!!!

     

  22. Jen M March 15, 2016 at 2:19 am

    I have gotten to the last part about the wordpress install… I put the wordpress unzipped folder/files in the /Applications/MAMP/htdocs folder… but can’t seem to get the MAMP program to run the install…

    In the Hosts section of MAMP, I added a server named:

    localhost:80/wordpress/wp-login.php but it stays RED and doesn’t work – only opens a NULL window in Safari…

    You mention to browse to the installer, so in that same MAMP Hosts section, I have the document root set to: /Applications/MAMP/htdocs/wordpress/wp-admin since that is the folder where the installer is located… but no luck. I’ve tried it at just /Applications/MAMP/htdocs but that also isn’t working either.

    Any advice?!

    • Tom Ewer April 1, 2016 at 7:47 am

      Hello Jen! I think you’ve gotten into a muddle – when installing WordPress, we’re not looking at adding anything into the Hosts section. The WordPress download should go into the folder you named in the htdocs folder within your MAMP installation. From there, make sure MAMP is running, then open a new browser window and type localhost:port/folder_renamed/wp-login.php. Of course, the port and folder_renamed text need to be specific to your installation.

      Take a few steps back if you have to, making sure to not go ‘off-piste’ as that can cause you issues! Good luck 🙂

  23. Shea March 28, 2016 at 1:19 am

    I have carefully gone through each and every step in this tutorial but as soon as I try to navagate to my address on my mac (localhost:port/my_wordpress/wp-login.php.)  I get a pop up saying, “There is no application set to open the URL localhost:port/my_wordpress/wp-login.php..” and it gives me the option to search the app store for an application to open the URL or to choose an application that I already have installed that could open it. I clicked, Search App Store but it just brought me to the app store and I didn’t even know where to start or what I would be looking for. When I tried clicking Choose Application… , it gave me options of possible apps that I already had downloaded that could open the URL (including MAMP)  but when I clicked an app, it would bring me into a smaller and smaller document each time I clicked. There seemed to be an infinite number of documents… help is needed my way:(

    • Tom Ewer March 30, 2016 at 7:50 am

      Hello Shea. Make sure that your port number is correct. The URL should not literally say localhost:port. On some machines it’s localhost:80 and others it’s localhost:8888. You can find your port by opening the MAMP Preferences screen, and looking in the Port tab. The correct port number for you will be within the Apache Port box.

      Hope this helps, and good luck!

  24. Daniel JHEELAN May 5, 2016 at 2:11 pm

    Hi,

    I was using Wamp for years but with virtual Hosts, it was becoming too complicated.

    I started using MAMP and my local server is using port 8888 and WordPress is installed under:

    http://localhost:8888/WordPress/En.

    The issue is that I always got Error establishing a database connection  when i used only “localhost” in config.php of WORDPRESS.

    MYSQL is using port 8889 ( check in preference of MAMP) and the only way for WORBPRESS to work was to change localhost to local host:8889 in the config.php of wordpress.

    FROM:

    /** MySQL hostname */
    define(‘DB_HOST’, ‘localhost’);

    TO:

    /** MySQL hostname */
    define(‘DB_HOST’, ‘localhost:8889’);

    Hope this will help others.

    Daniel

     

     

    • Luke May 5, 2016 at 3:57 pm

      Thanks for the share Daniel! I’m sure it will help others 🙂

  25. Tan May 30, 2016 at 6:19 am

    Great write up!

    I’m just wondering, if you were to set up the localhost on your local machines hard drive, and then you were to upgrade your hard drive, is it a simple case of copying and pasting the folder onto your new hard drive?

    Or would you need to do some sort of move process to get the local server to the new hard drive?

    Thanks

  26. Peter September 5, 2016 at 8:51 pm

    I just bought Mamp Pro 4 and it’s terrible. it constantly crached

  27. James September 13, 2016 at 12:46 am

    Hi 🙂

    All is well, but when i try to install the Avada theme,,, i get an error “style sheet is missing”

    I manually install too, and same error.

    It’s the same file i have used online.

    But, it’s not working locally.

    Can you please help?

    Thx 🙂

    James

  28. Wylie Horn September 16, 2016 at 2:00 pm

    I get as far as this stage:

     

    localhost:3306/Users/wylie/Documents/Sites/Wordpress/wp-login.php.

    Then the wp-login.php file downloads to my Downloads folder. Any ideas where I am going wrong?

  29. Ngwanamosadi September 27, 2016 at 6:14 pm

    Top article this. Thank you!

    • Luke September 28, 2016 at 5:32 pm

      You’re most welcome, Tom certainly did a fantastic job 🙂 Highly recommended!

  30. Eric October 13, 2016 at 7:34 pm

    Hey bro good stuff thanks. Quick question though… what if I already have the wordpress install and theme working on a live server and now I want to put it on my local machine too? Can I just FTP it locally? Would that suffice as the 5 minute install? Thanks bro

  31. Richard December 8, 2016 at 3:07 am

    Thanks for the help. Really great guide.

  32. Steve Murray February 13, 2017 at 12:40 pm

    I know this page is quite old, but I’ve just tried to do this and PHPMyAdmin is greyed out as it says it needs PHP 5.5.x to PHP 7.0.x and I appear to be running PHP 7.1.1, which is in the MAMP folder so I’m not sure why it’s an incorrect version. Any idea how to resolve this? Can I roll back my version of PHP?

    • Luke February 13, 2017 at 12:46 pm

      Hello! The directions are still valid … hmm, I’d try to remove MAMP and reinstall it, make sure to grab the latest folder. Then in the settings you can choose which PHP version is used.

    • hay April 16, 2017 at 10:58 am

      I had this problem too, but you can change the PHP in MAMP under preferences<PHP and you can change it to 7.0.15 and it fixes it.

  33. Jen April 19, 2017 at 3:23 pm

    I’m having the same problem as Steve Murray… “PHPMyAdmin is greyed out as it says it needs PHP 5.5.x to PHP 7.0.x and I appear to be running PHP 7.1.1, which is in the MAMP folder so I’m not sure why it’s an incorrect version.”

    Reinstalled from latest download and no resolution.

    • Luke April 20, 2017 at 3:10 pm

      Hello,

      We’re not able to replicate that, I asked some of our staff as well. Maybe search online through MAMP support to see if they know of anything.

      Thanks

  34. Vidal Kitoko May 7, 2017 at 8:18 am

    I ran into same issue and Hay’s solution worked fine for me.

    Just changed PHP standard version to 7.0.15 in MAMP.

  35. Ivan May 24, 2017 at 6:05 pm

    So many thanks – I’m (I think) 95% of the way there, but like a previous comment I can’t get to the actual WP installation.

    I’ve used standard folders with port set to 80, so in Safari I type:

    localhost:80/applications/mamp/htdocs/wp-login.php

    …and get “Not found – The requested URL /applications/mamp/htdocs/wp-login.php was not found on this server.”

    Am I being obviously dumb or…?

    Thanks

  36. Kirstov July 3, 2017 at 6:33 am

    Wow Tom it’s very complete… cheers for it…

    if you interested maybe you can try our Export database plugin too if you have feedback?

    https://wordpress.org/plugins/export-database-littlebizzy/

    We will appreciate it. No problem if cannot try.

  37. cfish4 September 7, 2018 at 9:15 pm

    Is it a good idea or a bad idea to create my local installation database using the same name/user/password as the live site’s database? Once I’m done making updates to my local installation, I will be migrating it to a server where it will replace the original site.

Leave A Comment

Recent Posts

Recent Tweets

For privacy reasons Twitter needs your permission to be loaded. For more details, please see our Privacy Policy.
I Accept