How to create a WordPress staging site

A staging site is a copy of your live site at a separate address, such as staging.example.co.za. Break it all you like, then push what works to the live site.

Before you start

  • Staging uses disk space equal to your live site. Check you have room.
  • Have a recent backup of the live site anyway.
  • Decide on a subdomain name. staging or dev is conventional. The free SSL certificate covers the subdomain automatically once it exists.

Option 1: Softaculous

  1. Open WordPress Manager:
    • cPanel: WordPress Manager by Softaculous, or via Softaculous Apps Installer.
    • DirectAdmin: Extra Features → WordPress Manager by Softaculous.
  2. Find the live site and choose the option to create a staging copy.
  3. Choose the subdomain. If it doesn't exist yet, create it first under Domains (cPanel) or Account Manager → Subdomain Management (DirectAdmin).
  4. Leave the directory blank to install at the subdomain root.
  5. Leave the suggested database name.
  6. Start the staging copy and wait. A large site takes several minutes.

Log in to staging at https://staging.example.co.za/wp-admin with your usual credentials.

Push staging to live

  1. In WordPress Manager, open the staging site and choose the option to push to live.
  2. Choose what to push:
    • Files only: theme and plugin changes, no content. Safe for most design work.
    • Files and database: everything. This overwrites live content with staging's copy: posts, comments, orders and form entries created on live since you made the staging copy are lost.
    • Selected tables: for shops, push files plus only the tables you changed, never the order tables.
  3. Take a backup of live first if the tool doesn't do it for you.
  4. Check the live site, then purge caches.

Option 2: WP Toolkit (most cPanel servers)

  1. In cPanel, open WP Toolkit. If it isn't there, use Softaculous.
  2. On the site's card, choose Clone.
  3. Choose to create a subdomain for the copy, or pick an existing empty one.
  4. Start the clone. WP Toolkit copies files and database and updates the URLs.
  5. The clone appears as its own site card.

To copy changes back to live, use WP Toolkit's option to copy data from the staging site to the live one. Choose files, database or both, and create a restore point first.

Option 3: By hand

No manager available? Create the subdomain, install a fresh WordPress there (see How to install WordPress), then use a migration plugin such as Duplicator or All-in-One WP Migration to export live and import into staging. Reverse the process to go live.

Keep staging private

  1. On staging, go to Settings → Reading and tick Discourage search engines from indexing this site.
  2. Password-protect the folder. See How to password-protect a folder.
  3. If the site sends email (shop orders, forms), disable outgoing mail on staging or point it at a test mailbox, so customers don't get duplicate notifications.

Good habits

  • Refresh staging from live before each round of work.
  • Don't leave staging running for months. Outdated copies get hacked and use disk space. Delete it when done.
  • Keep the same PHP version on both. See How to change my PHP version and PHP settings.

Problems

Problem Cause Fix
Staging shows the live site or a redirect loop URLs not rewritten, or a caching or security plugin holding the old domain In staging's wp-config.php add define('WP_HOME','https://staging.example.co.za'); define('WP_SITEURL','https://staging.example.co.za');. Disable caching plugins on staging
"Not secure" on the subdomain Certificate not issued yet Wait a few hours after creating the subdomain
Creating staging fails part-way Disk space, or a very large uploads folder Free space, or copy wp-content/uploads separately
Push overwrote live orders or comments Database pushed in full Restore the pre-push backup, then push files only or selected tables

Did this answer it?