Have you ever made a change to a client’s WordPress site and it crashed? Maybe you were updating a plugin or customizing code in the template, and the site just goes down. Panic sets in as you try desperately to bring the site back online. You realize visitors are seeing that the site is down, and are probably going to call your client soon. Not long after that, you’ll get a call from a very irritated client. As professional developers, we obviously want to avoid situations like this. So how can we? Well, instead of making code changes or updates to a live site, you want to test your changes to the staging environment. From there, you can transition them to the live site.
Staging Environment WordPress Usage Reasons
A staging environment is typically hosted on a private subdomain of your WordPress site for the purposes of building and testing. You might want to use this as:
Firstly, A blank canvas from which you build a new website or create new pages you plan to add to an existing website. This way, your clients, your managers, or anyone else who feels like weighing in before it’s appropriate to do so is prohibited from seeing your work until you’re ready to share. A mirror image of a live website you want to test new WordPress, plugin, or theme updates on. Updates are first handled on the staging site. Upon confirming that no issues are present, you can move forward with them on the live site.
Secondly, creates a mirror image of a live website you want to implement code or design updates to. This is especially helpful if you’re attempting to code a new feature on your own and are nervous about the repercussions of something breaking as a result. Clone of a live website you’ll use to save time developing a similarly structured WordPress site from-scratch.
Finally, a platform to stage a website pre-launch in order to conduct QA and testing. Team members, clients, and other project stakeholders are then given a link to the frontend of the staged site for review. The place to test new coding techniques. You can use a copy of a website that already exists or use a sample website to test out theories or to hone your implementation process before adding it to your workflow. You can also use this as a training platform for new developers on your team.
Staging Environment Benefits:
- Staging environments lend to safer coding practices, in general.
- They give you privacy to build and update websites without a bunch of prying eyes checking in on you.
- If something wonky gets introduced into the code, it won’t take down the live website or prevent complete access from the WordPress admin, which would reflect poorly on you as well as your client (if visitors were to notice).
- Staging sites save time you would otherwise spend repairing the white screen of death or troubleshooting other issues caused by cowboy coding on the live installation.
- They protect a live website’s search ranking as you prevent bots from encountering an error-ridden website, an offline website, or one that’s in transition and sending mixed signals.
As a result, the staging site is meant to maintain the integrity of the live site displayed to visitors. The following section explains how to go about setting one up.
Starting a Staging Environment
How you set up a staging environment depends on the purpose of it. If you intend on using it as a training or experimentation platform, you can do with it what you want. However, if you intend on using it for any other purpose (e.g. implementing WordPress updates, revising designs and code, adding new pages), then what sits in staging needs to be identical to the website.
This means having the same: Hosting. WordPress version. PHP version. Theme version. Plugin versions. Configurations that are essential to how the site works on the live host. To set up a mirror image of your WordPress site in the staging environment, you can use one of three means: the manual method, work with your managed WordPress host or use a WordPress plugin.
Managed WordPress Hosting
While the manual method has you working within the control panel and SFTP to set up a staging environment, there is another option outside of WordPress that will do the same thing. However, this one requires much less work on your part.
If your website has a managed WordPress hosting plan with one of these providers, you’re in luck: Most managed WordPress hosting plans with the providers above come with one-click staging or pre-made staging areas. All you need to do is log into your hosting account, and instantly create a password-protected staging site on your server.
Your WordPress host will also be able to save backups of your staging site, so you won’t have to worry about losing progress or “breaking” the test site without a quick way to reset it.
Pushing updates from a staging site to the live server is just as easy with this option. Just one click and your staging environment will go live.
By WordPress Plugins
For those of you who would like an option in between these two–one that requires less work on the server and doesn’t require the cost of managed WordPress hosting–use a WordPress plugin. I’m going to recommend two options here and, really, the difference boils down to your comfort with setting up WordPress Multisite.
Without Multisite: All-in-One WP Migration Plugin: All-in-One WP Migration is a plugin with multiple uses. It works as a backup plugin, a migration plugin, and yes, even as a staging plugin. But let’s focus on how to use this for staging.
- Install and activate the plugin on your WordPress site. Go to the All-in-One WP Migration menu on the sidebar and click on “Export”.
- Click on the “Add” button. In the Find and Replace boxes, enter the name of the live site as the “Find” and the name of the staging subdomain as the “Replace”. (This assumes you already created a subdomain for staging from your control panel.).
- Then, select Export to File. Click on the box to save it to your computer.
- Next, log into the WordPress installation for your staging environment (the one on the subdomain you created). Install the same migration plugin.
- Click on Import.
Upload the file you just saved to your machine. When you see this warning, click “Proceed”. And that’s it. You now have a mirror image of your live website sitting on your staging subdomain. To push your staging environment and any changes made there live, you simply have to reverse the process.
Cloner WordPress Plugin
There’s also the option to set up your subdomain on a Multisite network. One of the nicest perks of creating a staging environment this way is that you get to keep your live WordPress site and its private and non-indexable staging subdomain within one WordPress installation. So, you don’t have to move back and forth between your control panel and various WordPress instances to manage both.
- Activate Multisite (if it isn’t already).
- Back up you’re Multisite with Snapshot.
- Apply a new site to the Multisite network for your staging subdomain. Under the subdomain’s Info tab, uncheck “Public” and save your changes. You’re only going to want your admins to be able to see the site.
- Install Cloner on your Multisite network.
- Navigate to the Plugins menu and click on Settings for Cloner. From here, you can decide which parts of your Multisite subdomains are cloned. Save your changes.
- In the top admin bar, hover over My Sites > Network Admin and select “Sites”. Find the live website you want to copy, hover over it, and click “Clone”.
- If you have already set up the subdomain for the staging environment, choose “Replace existing Site” and find the name of it in the search bar. Otherwise, just create a new site on the network.
Finally, don’t forget to check “Discourage search engines from indexing the cloned site”. Then, click “Clone Site”. Go ahead and bypass the warning message if you’re sure you want to replace the subdomain with the live site’s content. Then, you should be ready to get to work on your staging environment. All settings, files, and database will mirror what exists on the live site.
In conclusion, To move the staging environment to the live server, you’ll simply need to reverse the process. There will be no need to create new sites or subdomains. Simply clone the subdomain to the live site once you have client approval on everything or you’ve verified that updates are good to go.
The manual method is simple enough:
- Save a backup of your WordPress site.
- Create a subfolder on your WordPress site.
- Install a fresh copy of WordPress on it.
- Copy files from your current site into this new WordPress installation.
- Copy your database from the current site over to this new installation.
- Create a subdomain from your control panel where this staging site will sit.
Think about all the time you’re going to save by using staging environments in your WordPress development workflow going forward. Whether it’s to prevent receiving unwarranted feedback from clients, as a result, keep your site safe when issuing updates, in addition, to code new features in a separate environment, staging environments preserve the integrity of your live WordPress site until you’re 100% sure those updates can be reflected on the frontend.