A staging site is basically an exact replica of your existing website with two key differences:
- It’s not available to the public.
- Changes you make on your staging site have no effect on your live, public-facing website.
This allows you to test out changes to your WordPress site without risking breaking your live website. That means you can try new themes, plugins, code snippets, and more with zero risks.
Create a WordPress staging site with the WP Staging plugin
If you want a simple way to create a WordPress staging site, there’s a fairly new plugin called WP Staging. It’s a good option for testing out basic tweaks, or checking if new plugins or themes are compatible with your current setup.
For example, some more complex plugins might interfere with the rest of WordPress, causing some unexpected problems. Enabling such plugins on a staging site first is a good idea because you can check if everything’s in order. This lets you avoid any trouble and/or downtime after a failed update/install. WP Staging will handle this purpose flawlessly.
However, if you want somewhere you can really dig into your site’s code, I would use the manual process I outline in the next section.
Current Version: 2.7.9
Last Updated: December 18, 2020
To use WP Staging, you just need to install and activate it. Then, head to the WP Staging tab and click Create new staging site.
Give your staging site a name (for example, “dev” or “staging”) and then click Start Cloning.
The process might take a few minutes depending on how large your site is. Once it’s finished, you can access your staging site by following the prompt. You’ll need to log in with your normal username. Then, you’re free to start testing! You’ll always be able to tell when you’re on your staging site by looking at the orange admin bar:
And don’t worry – only users with admin accounts can access your staging site. Neither Google nor your website visitors will be able to view it.Go to top
How to create a staging site for WordPress manually
If you want a more open sandbox environment – one where you get to experiment with custom code modifications and etc., the next option is to manually create a staging site on a subdomain. It’s important that you use a subdomain, rather than a localhost so that your hardware environment is identical.
Below, I’ll show you step by step how to set everything up. The process might be a little tricky if you’re a WordPress beginner, but I’ll try to break everything down as simply as possible.
NOTE – before starting this process, make sure you have a recent backup of your site just in case.
Step 1: Create a subdomain through cPanel
First, you’ll need to create a subdomain to actually house your staging site. Go to cPanel and find the Subdomains option. Your cPanel might be styled differently, but the actual options should be the same:
Then, create a subdomain named “staging” or something similar:
Step 2: Create an FTP account for your new subdomain
Next, you need to create a new FTP account for your subdomain. This ensures everything is always kept separate.
Find the FTP Accounts option and click on it:
Then enter the new account details. Make sure the Directory matches the directory (Document Root) for your subdomain:
Step 3: Upload WordPress files to staging site
Next, you’ll need to use that new FTP account to upload your site’s files.
First, download the latest version of WordPress and upload that:
Then, you need to also copy over these three folders from your existing WordPress site:
Upload those to your staging site as well. If your folders are especially large, you might be able to use cPanel’s File Manager to speed up the process. Otherwise, FTP is totally fine. I personally use FTP – it just might take some time to run through large folders.
Step 4: Export / Import your database
Next, you’ll need to export your live site’s database and import it to your staging site.
To do that, I like a dedicated plugin called WP Migrate DB. Install and activate it, then run it by going to Tools → Migrate DB.
The plugin will automatically update all of the file paths in your database to point to your new staging site URL. This is absolutely essential to ensuring your staging site actually works. Just make sure you enter the same directory path and URL that you used when you created your subdomain:
Then export the database.
Next, you need to create a new database for your staging site and import all of the data. Head back to cPanel and find the MySQL Databases option:
Click it and create a new database:
You’ll also need to create a new database user:
And give that user access to your new database:
Then, go to PHPMyAdmin. Find the database you just created, click Import, and choose the file that WP Migrate DB exported:
Then click Go to import your database data.
Step 5: Edit wp-config.php to point to new database
Last step! You need to edit the wp-config.php file on your staging site to use your new database details and username.
Also, make sure the database prefix matches the one used on your live site. You probably won’t need to change anything here – but it’s possible depending on what prefix your live WordPress site uses. For example, my live test site uses “wpov” as the database prefix, so I had to make that change.
If you’re editing the “wp-config-sample.php” file, make sure to rename it to just “wp-config.php”. Then upload it back to your server over FTP.
Step 6: Log in and restrict access to your staging site
If all went well, you should now be able to log in to your staging site using the exact same username/password as your live site.
There’s really just one more thing you need to do:
Restrict access to your site.
Start by going to Settings → Reading and choosing the Discourage search engines from indexing this site box. That will at least stop Google from indexing your site.