WordPress Tutorial

How to Create Staging Environment for WordPress

Introduction

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 staging.example.com subdomain (example.com 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

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

Refer to tutorial on databases and users for how to
add a privileged user to a 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:

define('WP_HOME','http://subdomain.domain.com');
define('WP_SITEURL','http://subdomain.domain.com');

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.

Conclusion

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.

Looking for a better way to host your website?

Transfer your website to the fastest web hosting platform with 24/7 dedicated support.

Join thousands of subscribers worldwide

and get awesome deals & the newest tutorials to your email

Please wait...

Thank you for sign up!

More in WordPress Tutorial
How to Add Web Push Notifications to WordPress

Close