While working with our WordPress website we may always need to test some new plugins, themes or code snippets. We can do such testing easily on our local WordPress installation. I have already covered the process of setting up a WordPress installation on our local computer using Instant WP. But sometimes there may be scenarios where a feature that worked well on a local installation is not working on a live server.
In the initial stages of setting up a WordPress site, we might have done such testing directly on the live environment. But once our website starts attracting visitors this is no longer an option. If something goes wrong during testing in the live environment, we have to restore our website from existing backups. This process of restoration may take quite some time. Such unexpected downtimes are not at all tolerable for a reputed website. So how can we solve this problem? The answer to this is to set up a WordPress staging site.
What is a staging website?
A WordPress staging website is basically a replica or clone of the actual live website in a closed environment. This means that our staging website will have all the features and contents of the live website but this site will not be accessible to the outside world. The concept of staging is not specific to WordPress. All professionally managed websites will have either a single or multiple staging environments for development and testing purpose so that any issues that come up during testing do not ever reach a live site.
In WordPress, staging site enables us to test our website thoroughly after introducing a new plugin or code modification. So if we are serious about our website then setting up a staging site is mandatory. Now let us discuss two different methods to set up a WordPress staging website.
Method1: Use Web Host Staging Feature
Many hosting providers have an option to set up a WordPress staging environment. The below image is a screenshot of Siteground ’s hosting plans from their website.
The greatest advantage of having a host provided staging environment is that we can easily move our staging website to the live environment without any hassle. If we are manually setting up a staging site then the process of moving staging environment to the live server may be a bit more difficult. Other hosts like FlyWheel, Kinsta, and WPEngine also provides a staging environment with their hosting plans.
If selecting a hosting plan with a staging environment is not a feasible option due to higher price tags, then we can go with the below-mentioned method to create a staging website manually for free.
Method2: Use WordPress Staging Plugin
There are many plugins available in the WordPress directory that helps us to create a staging environment. I have used the most popular WP-Staging plugin. After installing and activating the plugin we can see a WP Staging option in admin dashboard as shown below.
Now click the Sites/Start option in the menu. This will take us to WP-Staging plugin feature page. Click the Create new staging site button on this page.
Now we have to provide a name for our staging website as shown below.
If we click the DB Tables section it will list out all the tables that are about to get cloned for the staging website.
Normally we do not have to make any specific changes here. But if we wish to exclude some specific tables it can be done by unchecking the checkbox.
Note: WordPress tables are interlinked in many ways and so if we exclude any table from staging environment, some functionalities might not work. Be sure of the table that we are excluding before using this option.
If we are using some custom login URL other than the default WordPress login page then we have to click the Login Custom Link under the Login Options section. This will take us to another page as shown below.
Here we have to provide our custom login URL. After doing this click on the Save Changes button at the bottom. Now let us go back to our previous page and click the Start Cloning button.
The process will take quite some time depending upon the size of the live site we are cloning. This process actually copies our theme, plugins and all other related files to a different folder in the server. This will also create a new database with the existing data on our live website.
Once the process is complete we will have a screen as shown below.
Now we can click the Open Staging Site button on the screen. This will redirect us to the login page. Once the correct credentials are entered and validated we will be taken to our staging website. Now to understand how a staging site works let us create a new post in the staging website.
Once this post is created and published we can see it under the posts section in the staging site as shown below.
Now let us go to the same posts section in our live website admin.
The post that was created in the staging website is not available here. The same is the case with any new plugins or code changes in the staging site. So we can safely test our changes without the worry of any issues in the live environment. We also have the option to export/import the plugin settings under the tools section of this plugin.
The free version of this plugin does not allow us to migrate our staging site to a live environment. For this, we have to go with the paid version of this plugin.
From my experience, the staging environment created by this plugin has been really useful especially while testing out scenarios related to email subscriptions and contact forms. If you know about any better staging plugins do let me know via comments.
Leave a Comment