+254725682556 +254725052660 [email protected]
Client Area

Hosting

How to Create a Staging Copy of Your Website to Safely Test Changes

A staging copy is a private, working duplicate of your website that lives on a subdomain, separate from the live site your visitors see. It lets you test a theme change, a plugin update, or new code without any risk of breaking the site people are currently using. If something goes wrong, you simply fix it on the staging copy and your live site is never affected.

What You Need Before You Start

  • A subdomain to host the staging copy (for example staging.yourdomain.com).
  • A copy of your website's files.
  • A copy of your database, if your website uses one (WordPress and most other content management systems do).

Step 1: Create a Subdomain for Your Staging Site

Create a new subdomain to hold the staging copy, so it has its own folder and does not touch your live site's files. For the full steps, see How to Create a Subdomain in cPanel and DirectAdmin.

Give it an obvious name like staging or test so you don't mistake it for your live site later.

Step 2: Copy Your Website Files to the Staging Subdomain

In cPanel

  1. Open File Manager and go into your live site's folder (usually public_html or a subfolder of it).
  2. Select all the files, then click Compress to create a single zip archive.
  3. Move or copy that zip file into the new subdomain's folder.
  4. Select the zip file there and click Extract to unpack it into the staging folder.

In DirectAdmin

  1. Open File Manager and navigate to your live site's folder.
  2. Select the files and choose the option to create an archive (zip).
  3. Copy the archive into the subdomain's folder and use the Extract option to unpack it there.

Step 3: Copy Your Database (If Your Site Uses One)

If your website stores content in a database, such as WordPress, you need a separate copy of that database for staging so changes you make there don't touch your live data.

  1. Create a new, empty database and database user for the staging site.
  2. Export your live database and import that export into the new staging database. See How to Import and Export a MySQL Database Using phpMyAdmin for the full steps.
  3. Open the staging copy's configuration file (for example wp-config.php on WordPress) and update the database name, username, and password to match the new staging database.
If your site uses full URLs stored in the database (common with WordPress), you'll also need to update the site URL settings so the staging copy points to the staging subdomain instead of your live domain.

Step 4: Keep the Staging Site Private

A staging site is a work in progress, so you don't want search engines indexing it or visitors stumbling onto it by accident. Two simple ways to do this:

  • Password-protect the staging subdomain's folder so only you can access it.
  • Add a line to the staging copy's robots configuration telling search engines not to index it.

Testing and Moving Changes Live

Make your changes on the staging copy first: update a plugin, try a new theme, test a code change. Once you've confirmed everything works correctly, repeat the file and database copy process in reverse, from staging to live, or apply the same change manually on your live site.

Keep the staging copy around for future updates rather than deleting it after each use, so you always have a safe place to test before changes go live.