A staging website is a private clone of your live site where you can test changes without affecting your visitors. This is essential for testing WordPress updates, plugin changes, and design modifications.
Why Use a Staging Site?
- Test updates safely — plugin and theme updates can break your site
- Develop new features — build and refine before going live
- Debug issues — reproduce and fix problems without downtime
- Client approval — show changes to clients before publishing
Method 1: Manual cPanel Setup
Step 1: Create a Subdomain
- Go to cPanel > Domains > Subdomains (or Domains on newer cPanel)
- Create
staging.yourdomain.com - Set the document root to
/home/username/staging.yourdomain.com
Step 2: Copy Website Files
In cPanel > Terminal or via SSH:
cp -R /home/username/public_html/* /home/username/staging.yourdomain.com/
Or use File Manager to copy the contents of public_html to the staging directory.
Step 3: Clone the Database
- Go to cPanel > phpMyAdmin
- Select your live database
- Click Export > Quick > Go to download a SQL file
- Create a new database in cPanel > MySQL Databases:
- Create database:
username_staging - Create user:
username_staginguser - Add user to database with All Privileges
- Create database:
- In phpMyAdmin, select the new database
- Click Import > select the SQL file > Go
Step 4: Update wp-config.php
Edit wp-config.php in the staging directory:
define( 'DB_NAME', 'username_staging' );
define( 'DB_USER', 'username_staginguser' );
define( 'DB_PASSWORD', 'your_staging_db_password' );
Step 5: Search and Replace URLs
The database contains your live domain in hundreds of places. Use a search-replace tool.
In phpMyAdmin, for the staging database, go to the SQL tab:
UPDATE wp_options SET option_value = REPLACE(option_value, 'https://yourdomain.com', 'https://staging.yourdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
For a thorough replacement, use the Better Search Replace plugin or the WP-CLI command:
wp search-replace 'https://yourdomain.com' 'https://staging.yourdomain.com' --path=/home/username/staging.yourdomain.com
Step 6: Password-Protect the Staging Site
In cPanel > Directory Privacy, select the staging directory and enable password protection. This prevents public access.
Step 7: Block Search Engines
Add to the staging site's wp-config.php:
define( 'WP_ENVIRONMENT_TYPE', 'staging' );
In WordPress, go to Settings > Reading and check Discourage search engines from indexing this site.
Also add to the staging .htaccess:
Header set X-Robots-Tag "noindex, nofollow"
Method 2: WP Staging Plugin (Easier)
The WP Staging plugin automates the entire process.
Setup
- Install WP Staging from Plugins > Add New
- Activate the plugin
- Go to WP Staging > Staging Sites
- Click Create New Staging Site
- Optionally exclude large directories (uploads) or database tables to speed up cloning
- Click Start Cloning
The plugin creates the staging site at yourdomain.com/staging (or your chosen name).
Using the Staging Site
- Access your staging site at the URL provided
- Log in with the same WordPress credentials
- The admin bar shows an orange "STAGING" label so you always know which site you are on
- Make your changes, test thoroughly
Push Staging to Production (Pro Feature)
WP Staging Pro allows pushing changes from staging back to production:
- On the staging site, go to WP Staging > Push Changes
- Select what to push (files, database, or both)
- Exclude sensitive files (wp-config.php)
- Click Push
Pushing Manual Staging to Production
If you used the manual method:
- Back up your live site first
- Copy modified files from staging to production
- Export the staging database and import into the live database
- Run search-replace to change staging URLs back to live URLs
- Clear all caches
Best Practices
- Always back up before pushing staging to production
- Keep staging in sync — re-clone periodically to avoid drift
- Never index staging sites — always block search engines
- Use the same PHP version on staging as production
- Test on staging first — every time, without exception
- Delete old staging sites when no longer needed to save disk space