How to Set Up a Staging Environment for WordPress with Cloner

Premium hosting plans usually make it pretty easy to create private staging sites. However, lots of WordPress sites are hosted on low-cost hosting plans that don’t include these features. So I’m going to show you how you can use Multisite and a couple of our plugins to create a staging site system that will run on nearly any hosting plan.

My personal hosting needs are quite modest. In addition to my own site, I run a handful of low-traffic hobby and niche-interest sites. While I’d love to have a hosting plan with a premium managed WordPress web host, my hosting needs don’t justify paying for a premium account. So I make do with a standard shared hosting plan, the sort of plan you see advertised for around $10 per month.

While my hosting provider does offer staging sites, I’d have to bump up to a more expensive plan to get access to them. As a result, I’ve never had the luxury of using automatic staging sites when working on my personal projects.In this tutorial, I’m going to show you how I used three plugins to create a WordPress-powered staging site system that runs flawlessly on my shared server hosting plan.

In this tutorial, I’m going to show you how I used three plugins to create a WordPress-powered staging site system that runs flawlessly on my shared server hosting plan.

WPMU DEV offers premium Multisite plugins and I used the products mentioned her to build my staging site system.

In this tutorial, I’m going to demonstrate how to use the same products I used. However, it is possible to use alternative plugin. Just keep in mind that I haven’t actually tested any alternative plugins, only WPMU DEV options, so be sure to try them out in a local development environment before using them on your live website.

A Birds-Eye View

Here’s a high-level overview of how the staging site system will work:

A staging site will be created as part of a multisite network.

The privacy settings of the staging site will dictate that only site administrators can see it.

A plugin will be used to clone a production website that is also part of the Multisite network to the staging site.

Changes can be made to the staging site without affecting user experience on the live site.

Once changes to the staging site are finalized, the process is reversed and the staging site is cloned back to the live website.

Throughout the entire process, backups of the staging site and live site should be created to ensure there is always a backup on hand in the event that something goes wrong.

Getting Set Up

Activate Multisite, But Play It Safe

If you’re going to use this tutorial to add a staging site to an existing WordPress website, I urge you to go through the process locally at least once and to make a complete backup of your website before enabling multisite and building out the staging system. If you’ve never used a local development environment, our XAMPP, MAMP, or Vagrant tutorials will get you started

If you’re working with a site that’s already live on the internet, the first step is to create a complete backup of your website files and database. The best option is Snapshot Pro. Just create a complete backup and set it aside where you can easily find it in case something goes wrong.

With a backup of your site on hand, the next step is to enable Multisite.

The easiest way to install these plugins is to install the WPMU DEV Dashboard first, and then to navigate to WPMU DEV > Plugins to install both of these plugins.

With a website backup in hand, Multisite activated, and site cloning and privacy plugins installed and network activated, your staging system is now set up.

How to Use Your Multisite Staging Environment

Now that your staging site system is set up, you need to know how to use it. The primary tool you’ll be using is the cloning plugin. Just don’t forget to create backups along the way so that you can restore your work if something goes wrong.

Step 1: Create a Staging Site

Navigate to Network Admin > Sites and select Add New. Create a site which you will use exclusively for staging purposes and name it something that will make it easy to identify.

Create a blank site to use as your staging site.

Once you’ve created the site, access the site’s dashboard and go to Settings > Reading to access the site privacy settings. At the bottom of the list of options, you’ll find a radio button to limit site access so that Only administrators can visit. Select this radio button and then Save Changes.

Limit access to the staging site to Admins.

Step 2: Clone a Production Site to the Staging Site

It’s a good idea to create a complete backup your production site at this point. If something goes wrong, such as accidentally cloning your staging site over your production site rather than vice versa, you’ll have a clean backup to work with.

To clone a production site to the staging site you’ll need to access the Network Admin dashboard. From there, navigate to Settings > Cloner. Make sure that all of the checkboxes are selected.

Make sure all checkboxes are selected to create a complete clone.

To clone a site, go to Sites, hover over the site you wish to clone, and select Clone.

Hover over the site you wish to clone and select Clone.

On the next screen, select Replace existing site. To select your staging site, start typing in the URL for your staging site.

Type the site URL slug to prompt Cloner to locate the site.

Type in anything else, such as the site name or the full URL beginning with localhost, http, or www, and the plugin will not locate and suggest the staging site. So double-check your staging site URL and start typing it exactly as it appears to get the plugin to find the correct site. In my case, the staging site URL is http://localhost/site1stage, so typing in si caused the staging site to appear as a autocomplete option.

Once you’ve selected the appropriate URL, select the radio button to Keep the destination blog title. Leave the Advanced Options tables alone unless you know that you want to clone any table(s) left out of the cloning process by default, then scroll down and click Clone Site.

Next, Cloner will try to keep you from making a mistake.

Always read the warning message to make sure you’re cloning the right site to the right destination.

Read through the warning, confirm that you haven’t made a mistake, and select Continue.

Once you’ve started the cloning process it can take a couple of minutes, especially if you’re cloning a large site or your site is hosted on a slow server. Get comfortable and let the cloning process run its course.

Step 3: Dev to Your Heart’s Content

If privacy settings are configured properly, you’ll have to be logged in as an admin to view the staging site

You’re now set to develop your website using your private staging site. However, before you start, it’s a good idea to double check your staging site’s privacy settings.

Go to Settings > Reading and make sure that the site is only accessible to administrators. To check this, try to access your site in a browser window in incognito or private mode. If the privacy settings are set up correctly you’ll be prompted to login in order to view the site.

Step 4: Clone the Staging Site Back to the Live Site

Before cloning the staging site back to the live website, make a backup of both sites – or if your network only includes your staging and production sites, you can backup your entire Multisite network. Once you have a backup, you’re ready to push your staging site live to the web.

I always recommend picking a low-traffic time to make changes to a live website in order to minimize the impact on your website visitors. While the cloning process should have a negligible or non-existent impact on your website visitors, if all goes according to plan, in the unlikely event that something goes wrong you’ll be glad you attempted the process during a low-traffic time period.

Cloning your staging site back over the production site is basically the same as the cloning process completed previously.

Go to Network Admin > Sites;

Hover over your staging site and select Clone;

Select Replace existing Site and type in your production site URL or leave the box blank to clone the staging site over the main network site;

Select the checkbox to Keep the destination blog title and uncheck the box to Discourage search engines from indexing the cloned site unless you don’t want search engines indexing your website; and

Select Clone Site.

You’ll see the Cloner warning message. Read through it to make sure you haven’t made a mistake. If everything looks OK, click Continue and sit back and wait for your staging site to clone back over your production site.

Once the cloning process has finished, access the admin of your production site and check the privacy settings in Settings > Reading to make sure your production site is fully accessible to website visitors and search engines.

Pushing Changes from a Staging Site

Using WordPress Multisite to create a private staging site makes it easy to push changes from a staging site to a live website. It’s also an ideal environment to use for uploading a website developed locally without pushing those changes live to the web right away.

One thing to remember when using staging sites running Multisite is that your staging site is powered by the same WordPress installation as your live website. What this means is that you should be careful when installing plugins or themes, and modifying php files.

Ideally, you’ll use your staging site in combination with a local development environment. The staging site makes it easy to make website design and layout changes and then push all of those changes live in one fell swoop. However, all plugins, themes, and custom programming should be tested out using a local environment before you test them on your live Multisite network.

Do you use WordPress Multisite to create staging sites? What has been your experience? Let us know in the comments below.

Jon manages operations for Kinsta, a managed WordPress hosting provider. When he isn't figuring out the ins-and-outs of supporting WordPress-powered businesses, he enjoys hiking and adventuring in northeast Georgia with his wife and kids.

Get fresh WP updates directly to your inbox.

11 Responses

Thanks for the guide! I have considered for a long time to move several of my websites, and a few of my clients sites into Multisite to easy my administration of said sites, and this adds another pro for that route.

If I could only force the developers of some of the more specialized plugins I use to be multisite compatible…

What about comments? Will new comments on the live site be preserved when pushing the staging site back to live?

Your concern about comments is well-founded. If you look at the Cloner settings you’ll notice that you do have the option not to clone comments. Unchecking that box will leave the existing comments intact. However, I’d still recommend using Snapshot (or another backup plugin) to backup your live site before cloning your staging site over it.

With Cloner you can clone from a subsite (http://mysite.com/mytestcontent) back over the main site (http://mysite.com). To do so, simply leave the “Replace Existing Site” field empty when cloning the staging site and it will be cloned over the main site.

I use a totally different method to host a staging site. I have a miltisite network anyway, but my staging site is an entire copy of the network and so on a totally different installation.

The issue that I have to work around, and I believe you still would with the method describe in this article, is that if you have a site that includes some sort of membership, or user created contents, or comments as andreherberth has asked about, then it’s a bit more challenging, because the answer is no, you can’t just switch between sites and keep all the content up to date. Although switching over to any new plugins or files is all good, any changes I’ve tested that include changes to settings or pages ( i.e. stored in the DB ) I still then have to go through and make those changes on the live site to.

You’re right. If you have user-created content (comments, posts, etc), then you do have to plan around preserving that content when you use Cloner (or your method of maintaining two instances of your network). With Cloner, you do have a few options you can “uncheck” such as comments, users, custom post types, etc, and the unchecked items will be left intact on the site that you clone over. This may take care of some of the issues you mention, though perhaps not all. A little testing would be in order to make sure you don’t accidentally overwrite new content.

This is a great tool and it does exactly what it says it will do. Your directions are very clear, however; I spent literally hours and hours going back and forth with with support due to one little issue. I kept putting different variations of the url of the site I was replacing with the clone. I kept getting a message “The site you are trying to replace doesn’t exist”. Finally, I tried just entering the name of the staging site, but only everything after the m/ (m for multi-site).

If you have a single site that has been live for a couple years, and want to change it to a multisite (for this purpose) is there anything you need to be aware of, other than making backups and testing locally first? I seem to recall reading something, and can’t find it now, that suggested you were best not to try and change from single to multi after a period of time.

Thank you for this great tutorial. How is SEO impacted, if any, when cloning and replacing existing site with the staged site? If there are any impacts, what are some best practices during the cloning? Thank you again!