Hosting Tutorial & Guide

How to Create a WordPress Staging Site for Testing Changes

updated on Jul 04, 2016
How to Create a WordPress Staging Site for Testing Changes It is not a rare case to see a WordPress site break down after a plugin is installed, the WordPress core is updated, or a theme is modified. If you have experienced such troubles, you must have found how annoying they are.

If you happen to have a new backup, you can simply restore your WordPress site from the backup without losing anything important. However, if you are not that lucky, you may suffer a big loss of data and website modifications.

Fortunately, there is a solution for preventing these troubles from happening – by testing significant website changes on a staging site first before applying them to your production (live) site. This beginner tutorial, therefore, is going to show a simple way to set up a staging site properly, which is applicable to all skill levels.

What Is a Staging Site?

A staging site refers to a duplicate of your live site that is created for you to test themes, plugins or custom code. This site usually runs on the same server as the live site and is operated with a subdomain. After making sure everything works without any problem when changes are applied, you can copy your staging site to the live site or make changes on your live site directly to make them effective.

Many developers would keep a local copy of their sites for development purpose, so they can test things easily. However, a common problem with the local environment is that you may meet the trouble that something working on the localhost doesn't work properly on the live site, which could cause errors on your production site.

This is why you need a staging site. You can prevent accidents either by making changes directly on your staging site whenever you want, or by uploading the changes made locally to the staging site before applying them on a live site.

For beginners, the easiest way to create a staging site for a live WordPress site is to use a managed WordPress hosting package from providers like BlueHost which eliminate the difficulty by offering the easy-staging functionality.

Alternatively, you can set up a staging site manually by following the simple guide below if you are not on a managed server or cannot afford a managed WordPress hosting package.

Make a Staging Site Prepared

Before copying anything from your live site, you first need to make a staging site ready by doing all the following things.

Set up a subdomain for the staging site

A staging site is recommended to operate on a subdomain, so that you can run the site with a separate directory without affecting the files, uploads or database of your live site.

If you haven't got a subdomain, then you have to create one in your hosting control panel. Let's take cPanel for example. Firstly, log into cPanel, find the "Domains" section, and click on the icon of "Subdomains".


Secondly, fill in the name you want to use for the new subdomain. This could be "dev", "staging" or something else that is easy-to-identify. Then, select the main domain name from the dropdown which is usually the domain of your live site. This will generate a value for the "Document Root", and the directory shown here is where you will be able to upload files. The default value is good, while you can still make changes according to your needs.

Create a Subdomain

At last, click on "Create". You may need to wait for several hours for the subdomain to become active. After the subdomain is set up properly, you can visit it and see a page similar to the following screenshot.

Visit the Subdomain

Create a separate FTP account

If you are used to managing files through FTP, you also need to create an FTP account for the subdomain. This FTP account should be dedicated to the staging directory, with no access to other directories, so that you will not make changes to the live site mistakenly.

To create such an FTP account, locate the "Files" section in cPanel, click on "FTP Accounts", and fill in the required form with the login credentials you want. Pay attention that the domain should be the subdomain used by the staging site.

Create an FTP Account

Upload WordPress

After the new subdomain is set up, you need to download a fresh copy of WordPress from, extract the zip file to a folder on your PC, and then upload the folder to the staging directory on your site by using an FTP client or the File Manager in cPanel.

However, DO NOT run the installation script yet because you haven't got a database ready. This should be done later.

Set Up the Staging Site

To make your staging site working in the same way as your live site, you have to pull the necessary data from the live site to the staging site. Here are the detailed instructions.

Copy the database of your live site to the staging site

This can be done easily with phpMyAdmin. After logging into phpMyAdmin through cPanel, open the database of your live site, and click on the "Operations" tab.


There, you will see a section of "Copy database to". In the text box, you should enter the name of the database used by your staging site. If you haven't created a database for the site yet, you need to get the "Create Database" option checked, and then enter a database name like "bhs_staging" in the text box. By doing so, a database will be created automatically before the existing database is copied.

Then, make sure the "Structure and data" option is checked, and leave other options to the default. After the button "Go" is clicked, the copy starts running.

Copy Database

Once the database is copied successfully, open the database of the staging site, and click on the "SQL" tab. Then, run the following SQL queries to replace the references of the live site with those for the staging site so that the database can work for staging.

Run SQL Queries

For these SQL queries, you have to replace three values with your own. The first is the "livesite_URL" which means the URL of your live site, for example, The second is "staging_URL" which is the URL of your staging site, e.g. And the last one is the database table prefix. The default is "wp_", but if you are using a custom prefix, make sure to modify it.

Copy the needed files

Now that you have dealt with the database, the next task is to copy the themes, plugins and media files to the staging site. To be more specific, you need to copy these directories.
  • /wp-content/themes
  • /wp-content/plugins
  • /wp-content/uploads
You can manually download these directories from the live site and then upload them to your staging directory with FTP or the File Manager in cPanel. Or you can make use of cPanel and copy these directories directly on your server to make the process quicker.

After accessing the directories you need with File Manager, you can right-click any of these directories, select "Copy", and then enter the destination path. After clicking on "Copy Files", the process is automated, and you will see the directory and all the files in it appear in your staging directory as soon as the copy is finished.

Copy Files to Staging Site

You must pay attention that you have to copy the needed directories one by one because File Manager doesn't come with the bulk-copy functionality.

Connect WordPress to the staging database

Now you can visit your new staging site with its subdomain. If the wp-config.php file doesn't exist in your staging directory, WordPress will create one now and ask for the database connection details including the database name and login credentials. If the file already exists, make sure to edit it with the right database information.

Once WordPress connects to the database successfully, you will get the login screen. The username and password you can use to log into the new site should be the same as those of your live site.

From now on, you are able to make any change to the independent staging site without affecting the users on your production site.

Things to Do after Setting up the Staging Site

After the staging site is created properly, you need to take more steps to make it work better. First of all, you have to visit Settings > General to check the "WordPress Address". If the subdomain shows up, everything is right, and if not, the SQL queries run before might have failed. Then, you may also need to check the media library, the plugins and themes to make sure all files have been copied to the right place.

Besides, the following tasks require being done, too.

Disable search engine indexing

For the staging site, you will not want it to be crawled and indexed by search engines. So right after logging into the site, go to Settings > Reading and tick the checkbox after "Search Engine Visibility".

Turn Off Search Engine Visibility

Restrict access to the site

The staging site should not be publicly accessible. In order to prevent others from accessing the site accidentally, you can either install the Restricted Site Access plugin, or password protect the staging directory with .htaccess file.

Update permalinks

If you see 404 errors on the staging site, you can try fixing them by updating the permalinks. This can be done by going to Settings > Permalinks and clicking "Save".