How to Create Staging Environment for WordPress

How to Create Staging Environment for WordPress

WordPress is limited to preview changes in posts and pages. What if you want to preview a different theme with additional changes or completely re-make your website? Doing all this on a live WordPress site may be inconvenient for your visitors. This tutorial shows you how to create a staging environment for your WordPress site and develop it without affecting the live version.

What you’ll need

Before you begin this guide you’ll need the following:

  • Access to your hosting account control panel

Step 1 — Creating a subdomain for staging environment

Create a subdomain for your staging environment. In this example, we will be using subdomain ( being our main WordPress domain). If you are not sure how to create subdomains, refer to this tutorial for more details on how to create a subdomain in cPanel.

Step 2 — Copying your WordPress site’s files to a subdomain

Copy all the files from the existing WordPress installation to a newly created subdomain. In this case files will be moved from public_html/ to public_html/staging/. Refer to a tutorial on managing files via File Manager for more information.

Step 3 — Duplicating WordPress Database

Duplicate the existing WordPress database. In this example, we will copy database techno75_wp792 to techno75_staging. There are quite a few ways to duplicate WordPress database:

  1. You can use phpMyAdmin to create a copy the database as shown in this tutorial. However, this option may not be available on some hosting providers.
  2. You can create database backup file and then import it to newly created database.

On a newly created database there will be no privileged users. Don’t forget to add the same original user from your existing WordPress installation:

Adding a user to database

Step 4 — Configuring wp-config.php file of a newly created subdomain

Open up wp-config.php file located in your newly created subdomain (in this example it’s public_html/staging/wp-config.php) and add the following lines:


IMPORTANT: Change subdomain to your newly created staging subdomain and domain to your original WordPress domain.

Next, on the same file, change your database name and username to a newly created one:

define('DB_NAME', 'techno75_staging');:

Configuring wp-config.php file

The staging environment is now ready for use. To apply all the changes you have made to your staging copy of WordPress you need to copy the staging database back to the original one and do the same with all the files from the staging subdomain.


You have learned how to quickly create a staging environment for a WordPress site. You can also password protect the staging copy if you don’t want others to access it.

The author

Linas L.

Linas started as a customer success agent and is now a full-stack PHP developer at Hostinger. He is passionate about making a positive impact on people by utilizing user-driven development techniques. As much as he enjoys coding and changing the world, he secretly dreams of becoming a rock star.