Do you need help to create a WordPress staging site with cPanel?

A staging site (also known as a test site or development site) is a duplicate of your live site. It allows you to make changes privately without disrupting your live site. This is a very useful tool to learn if you are:

  • testing plugins for compatibility,
  • testing if your WordPress Theme is compatible with new WordPress updates,
  • implementing major features and content on top of your current site,
  • fixing glitches, bugs, or security vulnerabilities, and
  • building a new site, among many other reasons.

If your WordPress site is producing income or generating high traffic, learning how to create a staging site with cPanel helps minimise disruptions. For example, if something goes wrong on the staging site, it is as easy as reverting the change, or deleting everything, and duplicating your live site again very quickly.

In this tutorial, you will learn how to create a WordPress staging site with cPanel manually, essentially for free. Fortunately, there are plugins and services that you can use for convenience which may incur a fee, but if you are on a budget or just curious, then let’s get started!


Step 1: Create a subdomain

Login to your site cPanel and create a subdomain. Everyone’s cPanel will look different and would be normally found in Domain > Subdomain.

Make a note of where the staging folder sits in your directory. For example, the staging folder in this tutorial sits in: alexthedigitalproducer.com/public-html/staging (yours will be different).


Step 2: Duplicate the live WordPress site to the staging site

In cPanel Home, access File Manager and navigate to your ‘public-html’ folder. Copy everything and paste them into the staging folder.

Remember, if the ‘staging folder’ also sits in ‘public-html’, do not duplicate that folder.

After copying, go into the staging folder > find a file called ‘wp-config.php’ > right-click to View. Approximately 30 lines down, make a note of your database name and database username. This will be important throughout this tutorial.


Step 3: Duplicate the live WordPress site database

WordPress not only contains pages to display your site, but also a database that manages and pushes important data to ensure your site is looking and functioning correctly.

Exit File Manager > back to cPanel home > navigate to phpMyAdmin.

  1. On the left navigation bar, click on your live site’s database name.
  2. On the right panel, click Operations.
  3. Go to ‘Copy Database to’ subpanel and give your staging database a new name. For example, this tutorial will name the staging database as ‘atdp_staging’.
  4. Click Go to begin the duplication process. It is important to wait and not disrupt this process or else you may create a corrupted database without knowing.

Step 4: Configuring the staging database

  1. On the left navigation bar, click into the newly duplicated staging database.
  2. Navigate to ‘options’ table.

Note: Every WordPress database installation typically has their tables prefixed with something. For example: ‘wp_options’. Everyone’s table will look different, but most of the time, there will be a ‘[prefix name] _options’ table.

  1. Navigate to ‘siteurl’ and click Edit. Change the URL to the staging URL, then click Go.
    Tip: If you cannot find ‘siteurl’ in the table, go to Filter rows (*) and type it in.
  1. Repeat the same process for ‘home’ by changing the URL to the staging URL, then click Go.
  2. Exit phpMyAdmin and return to cPanel Home.

Step 5: Assigning the staging database to the database username

Previously in Step 2, remember you were asked to record the database username?

At cPanel Home, go to MySQL Databases > Add User to Database (heading)

Then, in the ‘User’ panel, refer to your notes from staging ‘wp-config.php’ database username. In the ‘Database’ panel, add the staging database name that was duplicated from phpMyAdmin.

Then click Add.

You’ll be directed to another page to provide permissions to the user (i.e. webmaster/administrator). Tick ‘All Privileges’ > Make Changes. Then exit MySQL Databases and go back to cPanel Home.


Step 6: Configuring ‘staging/wp-config.php’ file

Open File Manager > navigate to staging folder > right click on ‘wp-config.php’ file > click Edit.

You’ll be prompted with a warning. Create a backup of wp-config.php (in case you need to revert), then click Edit once more.

Approximately 30 lines down, change the database name to the one created from phpMyAdmin. Click Save Changes > Close

Exit File Manager and log out of cPanel.


Step 7: Finalising the staging site

We are almost there, well done for making it this far.

Go to your web browser > type in the staging site URL + wp-admin to access the backend. For example, https://www.alexthedigitalproducer.com/staging/wp-admin

Tip: The username and password are the same as the live site.

In Common Settings (heading), check Post Name > then Save Changes. This is important because the permalinks are still referencing to the live site. Updating this will reference to the staging site permalinks.


Finished…but wait!

That’s the end of the tutorial! You now have the tools to create a WordPress staging site with cPanel and you can now safely make edits on the staging site without disrupting your live site. But wait! What happens when you finish editing the staging site and want to migrate everything to live? You will find out in the following tutorial set to be released next week - watch this space.

If you found this tutorial useful, please leave a comment below and share this blog. Let us know if you have topics you would like us to cover in the future.

Happy staging!

Privacy Preference Center