How To Create A Staging Environment For WordPress

Johnny Greaves

When you need to make changes to your site, you need to make sure that you are testing them. Many people will risk it all and make big changes but what happens if something goes wrong? The best way to test out your chances is to create a WordPress staging environment. To do this, you will need to know a few simple steps. Keep reading to hear more about how to create a WordPress staging environment below.

What Is A WordPress Staging Site?

If you have never heard of a staging environment for WordPress then you should know that it is a private site. If you create this, you will not have any changes made to your live site and this is very important. The main purpose of this is to test out your changes including plugins and code snippets. Your site will be an exact replica.

Using A Web Host

There are a few different web hosts that you can use to create staging site WordPress. Many of the main sites like Bluehost, Kinsta, Flywheel and SiteGround off this as part of their service. Make sure to take a look at these and give them a shot when creating your staging site.

Using The WP Staging Plugin

WordPress actually have their own plugin which is useful for trying out some new themes. This is called WP Staging and it can come in handy. This is a basic plugin but it can help you to figure out if a theme is going to ruin your site or not.

Once you have this plugin and it is installed, you can easily head to ‘Create New Staging Site’. This will allow you to name your site and choose the ‘Start Cloning’ option. After a few minutes, you should have a staging site that you can login to and make some changes. You will notice an orange bar at the top of the screen to indicate that you are on the staging site. It is important that you only make changes on this site if you are not ready for them to go live on your main site yet.

Manually Creating A Staging Site

If you aren’t keen on the WP plugin then you might want something a little more customisable. You can do this by creating a staging site manually, although it will be a little trickier. When doing this, you should make sure that you are using a subdomain in order to make the environment identical. There are a few steps that you’ll need to follow to get this right the first time:

Step 1

The first step involves creating a subdomain to keep your staging site in. This can be done via the cPanel and the Subdomains option. You can then create your subdomain here.

Step 2

Next, you’ll need to create an FTP account to ensure that nothing gets mixed up. You can do this via the FTP Accounts option and adding new account details. Check your Directory here to ensure that everything matches.

Step 3

The next step is to upload your site’s files using your new FTP account. You will need to make sure that you have downloaded the latest version of WordPress to achieve this. Make sure that you copy over folders that include;

…/wp-content/plugins
…/wp-content/themes
…/wp-content/uploads

These folders should be added to your staging site. It is possible to speed this up but often FTP works fine for this task.

Step 4

The next step is to install a plugin called WP Migrate DB in order to export the database in your live site to your staging site. This should then be run by using the ‘Migrate DB’ option. You’ll notice that your file paths will be added and if you neglect this then your staging site will not work properly. Use the right directory path and then export your database.

Once you have completed this, you should import your data and return to the cPanel. Here, you will create a new database using the MySQL Databases option. Create a new user and give them access. The next step is to head to the PHPMyAdmin and import the database you created. You can then click the ‘Go’ button to make it happen.

Step 5

The final step in this process is to edit the wp-config.php file on your staging site. This will help you to use your username and details. Here, it is also useful to check your prefixes although this should usually work automatically. Any edits that you make to the wp-config-sample.php file should be renamed and reuploaded.

Step 6

You can test out your staging site by logging in and making sure that access is restricted. Make sure to do this by choosing the ‘Discourage search engines from indexing this site’ box. There are some plugins which can help you to restrict access further if you wish.

Pushing It Live

While it can be tempting to push your changes live using a button, this can be problematic. The last thing you want is to push the changes live through your site to then have it crash. Make sure that any changes that you make to your site are done manually and this should help to avoid any of these issues.

Final Thoughts

As you can see, there are a few ways that you can create a WordPress staging site, depending on what you are using it for. The best way to do so is by creating your staging site manually but this can be quite time-consuming. Make sure that you are choosing the right method for you and that you are always testing everything out on a staging site before pushing live. If you are going to follow any of our methods then don’t miss out on any of the important steps. This way, you can be happy with your changes and have a site that operates properly.

 

Johnny Greaves

Author Johnny Greaves

Johnny has been building websites for 9 years, from small family-run company websites to internal web-apps for large enterprises. He has a management degree from the University of Manchester and likes to break things to see how they work. As far as we’re aware he can function solely on coffee and jelly-beans.

More posts by Johnny Greaves