As the organizer of the Las Vegas WordPress Meetup, I'm constantly telling people that they should test new releases of WordPress using a staging site or on a local development site prior to running the update on their live site. Never has this been truer than with the upcoming release of WordPress 5.0 that includes the new editing tool named Gutenberg.
At this month's meetup, I ran through a VERY quick demonstration of how to set up a local copy of WordPress and then get a copy of a live website running locally. While it was a nice example of how it could be done in about 15-20 minutes, it was near impossible for the audience to take adequate notes. So as promised, here is a step-by-step tutorial on setting up a copy of a live site on a local install of WordPress.
Disclaimer: There are many, many, MANY ways this can be done. There are more technical ways to do this with other tools, but this is the way that I do it; and I feel is a reasonable way for even a non-technical person to follow along with.
Set up a web server
I've seen it happen before. Somebody wants to run WordPress locally, so they head over to WordPress.org and download a copy of the software. They unzip the file and become very confused that WordPress won't run. That's because WordPress needs to be run on a web server. One of the easiest ways to get a web server set up on your local computer is with a tool called Local by Flywheel. They have a version for either Mac or Windows; so it's a great tool that can be used by just about everybody.
The first step is to download Local by Flywheel and install it on your computer. Once that's done, we'll set up WordPress. You'll love how easy this is.
Set up a local install of WordPress
In this step, we're going to install a fresh copy of WordPress using Local By Flywheel. Start by reviewing the photo gallery.
- Click the green plus sign, or the “Create a new site” button.
- Give the site a name and Flywheel will fill in the Advanced Options automatically.
- Leave “Preferred” selected and click “Continue.”
- Add a username and password. They do NOT need to match your live website.
- On a Mac, you'll need to provide the admin username/password so that Flywheel can add a required system update.
- When you see this screen, WordPress is installed and ready to go. Click the “View Site” button to see your site in a browser.
- Here's my fresh install of WordPress.
And just like that, WordPress is installed locally. You can access the admin area using the username and password you typed in during the setup process.
With WordPress installed, now the real fun starts. Over the next few steps, I'll walk you through the process of bringing a copy of a live website down to the local install.
Install a few plugins
In the steps that follow, I'm going to move copies of the database, plugins, themes, and the files that have been uploaded to the media library. To do this, I'm going to use two plugins: Updraft Plus and WP Migrate DB Pro.
Updraft Plus is a free plugin. WP Migrate DB Pro is not. Yes, there are ways that you could do these steps manually so that you don't need the paid plugin. But, for the simplicity and time savings, I feel that the cost is 100% justified. You will need to purchase the Developer license of WP Migrate DB Pro in order to get Media Files Addon, which you will use to move all the files from your Media folder on the live site to the local install.
The next step is to install the following three plugins on the live site AND the local WordPress install:
- Updraft Plus
- WP Migrate DB Pro
- WP Migrate DB Pro Media Files Addon
Once you have installed all three plugins, go ahead and activate them and enter your license key for Migrate DB Pro on both the live and local install.
Download themes, plugins, and other files
In this step, I'm going to create a backup. Then, from the backup, I'll move those files down to my local install. First, let's make that backup and prepare the files we need. For this part, we're going to log into the WordPress dashboard on the live site and go to the Settings -> UpdraftPlus Backups tab.
- Go to the Settings -> UpdraftPlus Backups tab and click the big blue Backup button.
- Uncheck the “Include database” and click the “Backup Now” button.
- In the “Existing Backups” section, click the “Plugins, Themes, & Others” button next to the backup that was just created.
- Click the “Download to your computer” button next to each of the three items.
Notice that I didn't say to download the ‘uploads.' This is because, depending on the number of files in your media library, the backup file may be too large to import to your new WordPress install. We will deal with the media files in a later step.
Once those three files are downloaded, we can move onto the next step.
Add themes, plugins, and other files to local install
Next, I'm going to log into the WordPress dashboard on the local install of WordPress and go to the Settings -> UpdraftPlus Backups tab. Then, I follow these steps.
- In the “Existing Backups” section, click the “Upload backup files” link. Then, drag and drop the three files you downloaded where it says “Drop backup files here.”
- Click the “Restore” button next to the backup you just uploaded.
- Check the box next to “Plugins, Themes, and Other,” then click “Restore”.
- You will be asked to confirm your selection. Click “Restore” a second time.
- After a moment or two, you will see a “Restore Successful” message.
At this point, if you click on the “Appearance” tab, you should see the themes from your live site have been copied locally and are now available. It's the same with the plugins. With that, we're ready to move onto the next step.
Migrate the database and media files
Next, we'll start by going to the Tools -> Migrate DB Pro tab on the live website. Then, follow these steps.
- Click the “Settings” tab in the top menu.
- Click the “Copy to clipboard” button under the “Connection Info” box.
- Under “Permissions,” click the “Pull” button to allow the local site to pull information from the live site.
The live site is now set to allow the local site to pull a copy of the database and the media files. To do that, start by going to the Tools -> Migrate DB Pro tab on the local install and then follow these steps.
- Select the “Pull” option from the list of radio buttons.
- Paste the info you copied from the live site into the “Connection Info” box.
- Migrate DB Pro will automatically fill in the find/replace information so your live site will work on your local install.
- Scroll down and click the “Media Files” option. Leave the “Compare then download” option selected and click the “Pull” button.
- Migrate DB Pro will now pull down a copy of the database and media files. This process can take a few minutes, so be patient.
- Once done, you'll see a confirmation screen.
- You will automatically be logged out of the local site because the database and all login information has changed to match the live site.
- Your local site should now match your live site!
FAQs
One question that I get asked frequently about having a local copy of a website is, “Can I create content on my local website and push it to the live website?” My answer is always, “I don't suggest it.” The reason being, if you pull down a copy of the database from the live site on Monday and then take three or four days to make some changes locally and then you want to push it back up to the live server, any new activity that took place on your live site during that same time frame will be lost. There is no easy way (that I know of) to push only the changed data from the local site to the live site. There have been some plugins that have attempted it, but none that I can recommend at this time.
The other big question is, “Is there a way to set up a local install without having to pay so much for plugins?” To which the answer is “Absolutely!” As I said at the beginning of this post, there are many ways to set up a local copy of your website. But, the process I'm showing requires the least amount of technical knowledge. There are definitely less expensive ways to get the job done, but they will either increase the technical knowledge requirements and/or the amount of time it will take to get the process done.
Time to go test stuff!
Now that we've got a local version of our website, we have a perfect spot to test plugins/themes/software updates on our test site without affecting our live website. Right now, that probably means testing the upcoming WordPress 5.0 release with Gutenberg. The easiest way to test it is by installing the Beta Tester plugin on your new local install so that you can see how your live production site will likely perform prior to installing the most recent version of the software. DO NOT install the Beta Tester plugin on your live website. Only use it on your local development environment, as the software is still under development.
I hope you find this tutorial useful. I would love to hear your feedback. Did you run into any issues along the way? Let me know in the comments. Now get out there and test all the things!
Hi John,
Awesome step-by-step tutorial. Very easy to follow the steps that you have layout thank you.
I’m on my last step of migrating media file. Files are loading around 44 mb and 78 tables. Then I receive this error message.
Migration failed
JSON Decoding Failure — Our AJAX request was expecting JSON but we received something else. Often this is caused by your theme and/or plugins spitting out PHP errors. If you can edit the theme or plugins causing the errors, you should be able to fix them up, but if not, you can set WP_DEBUG to false in wp-config.php to disable errors from showing up. (#144)
View error messages
Unable to connect to the remote server, please check the connection details – 502 Bad Gateway (#129 – scope: ajax_determine_media_to_migrate_recursive)
I checked my WP_DEBUG on my live site and it is set to false. Any solutions or what I might be doing wrong?
Thanks Hal