Creating a staging site manually

Creating a staging site

A staging site is a safe copy of your live site where you can test changes, updates, or new features without risking downtime or breaking your main site. It allows you to check plugin/theme updates, try out custom code, or redesign your site before deploying those changes live.

This guide walks you through setting up a manual staging site in cPanel. The process involves creating a subdomain, copying your site files, duplicating your database, and updating the site to use the new staging environment.

We’ll be staging a WordPress site in this guide, but the process is the same for any website — just update the configuration files to match your specific application.

Take a backup of your site and database before you start. This procedure edits your database directly, and a mistake in the URL steps can affect your live site as well as the copy.

Follow the steps in the order given. In particular, do not open the staging site in your browser until you have finished the Update WordPress Site Links section — until then it still points at your live database.

Create a Subdomain

  1. Log in to cPanel.
  2. Go to Domains → Domains.
  3. Click Create A New Domain.
  4. Enter your staging URL (e.g. staging.example.co.uk).
  5. Untick Share document root so the subdomain has its own folder.
  6. Click Submit.
  7. cPanel will set up a folder, usually /staging.example.co.uk

Copy Your Website Files

Option A: cPanel File Manager

  1. Open File Manager.
  2. Go to your live site folder (Usually /public_html/).
  3. In Settings (top right), tick Show Hidden Files (dotfiles) first - otherwise .htaccess is not copied and your staging site's pages will all return 404.
  4. Select all files → Copy → choose the staging folder (/staging.example.co.uk).

Option B: FTP Client

  1. Connect via FTP.
  2. Download all files from public_html.
  3. Upload them to /staging.example.co.uk.

Export the Database

  1. In cPanel, open phpMyAdmin.
  2. Select your live site’s database from the left menu.
  3. Click Export at the top → QuickSQLGo.

Create a New Database

  1. In cPanel, go to MySQL® Database Wizard.
  2. Enter a name for the staging database (e.g. stagingdb).
  3. Create a new database user (e.g. staginguser) with a strong password.
  4. Assign the user to the database with All Privileges.
  5. Note down the database name, username, and password — you’ll need them.

Import the Database

  1. In cPanel, open phpMyAdmin.
  2. Select the new staging database.
  3. Click Import, upload your .sql file, then click Go.

Update wp-config.php

  1. Open /staging.example.co.uk/wp-config.php in File Manager.
  2. Update the database settings:
define('DB_NAME', 'user_stagingdb');
define('DB_USER', 'user_staginguser');
define('DB_PASSWORD', 'yourpassword');
define('DB_HOST', 'localhost');
  1. Save the file.

Do these in order. Until step 1 is done, the staging copy still believes it is the live site, and opening it in a browser will send you to your live admin instead.

  1. In phpMyAdmin, open the staging database and find the options table (it will have your install's table prefix in front of it - wp_options by default, but installers often use something else).
  2. Change the siteurl and home values to your staging URL. Include https:// and do not put a slash on the end - for example https://staging.example.co.uk.
  3. Now log in at staging.example.co.uk/wp-admin and install Better Search Replace.
  4. Search for your full live URL and replace it with the full staging URL - https://example.co.ukhttps://staging.example.co.uk. Do not search for the bare domain: it would match the staging URL you just set and produce staging.staging.example.co.uk, and it would rewrite every email address on the domain as well.
  5. Run it as a dry run first, check the number of changes looks sensible, then run it for real. Our guide to updating WordPress URLs covers this step in more detail.

Keep the staging site out of Google

Your staging site is on a public address, and left alone search engines will index it alongside your real site. In the staging site's admin, go to Settings → Reading and tick Discourage search engines from indexing this site.

Remove the staging site when you have finished

Once your changes are on the live site, take the staging copy down rather than leaving it in place. It is a complete WordPress install on a public address, and it stops receiving updates the moment you stop using it - so it becomes an unpatched way into the same hosting account your live site is on. Nothing lists it for you either, because you built it by hand rather than through an installer.

There are three parts to clear up:

  1. Delete the staging folder (/staging.example.co.uk) in File Manager.
  2. Remove the subdomain under Domains.
  3. Delete the staging database and its database user in MySQL Databases - the database user is easy to miss and is a live login if it is left behind.


How did we do?

Powered by HelpDocs (opens in a new tab)
© Krystal Hosting Ltd 2002–