How to Create a Staging Site on a WordPress VPS in 2026
Disclosure: Some links in this article are affiliate links. If you click and make a purchase, we may earn a commission at no extra cost to you. This does not influence our editorial recommendations - we only recommend products and services we genuinely believe in. Read our full affiliate disclosure.

Every experienced WordPress developer and site owner knows the cardinal rule: never test untested changes on a live production website. A poorly tested plugin update or theme modification can take down your WooCommerce store, break custom post type queries, or corrupt critical database tables in seconds.
The solution is a dedicated staging environment - an identical mirror of your production site running on a private subdomain where you can freely experiment, test updates, and validate changes before deploying them to your live audience.
On a VPS with SSH access, creating a staging site is entirely free and takes under 30 minutes using Nginx virtual host configuration, WP-CLI's powerful command-line tools, and rsync file synchronization.
Architecture Overview
Step 1: Create the Staging Directory Structure
Create a dedicated web root for the staging environment:
Step 2: Clone Production Files with rsync
Copy all WordPress files from your production directory to the new staging directory:
Set correct ownership so PHP-FPM can read and write files:
Step 3: Clone the Production Database with WP-CLI
Install WP-CLI globally if not already present:
Export the production database:
Create a dedicated MariaDB database and user for staging:
Import the production database export into the staging database:
Step 4: Configure wp-config.php for the Staging Environment
Copy and update the WordPress configuration file for the staging site:
Open /var/www/staging.example.com/public_html/wp-config.php and update the database constants:
Also add a constant to disable automatic plugin updates and email sending on staging to prevent accidental notifications to real customers:
Step 5: Search-Replace Production URLs with WP-CLI
The cloned database still contains all references to https://example.com. Replace them with the staging subdomain:
Flush the WordPress cache and object cache:
Step 6: Create the Nginx Virtual Host for the Staging Subdomain
Create a new Nginx server block at /etc/nginx/sites-available/staging.example.com:
Enable the configuration:
Step 7: Generate HTTP Basic Auth Password File
Create a password-protected access credential for the staging subdomain:
Enter and confirm a strong password. The /etc/nginx/.htpasswd file now contains the hashed credentials required to access staging.example.com.
Step 8: Issue Let's Encrypt SSL for the Staging Domain
Certbot will automatically configure HTTPS redirection. Your staging site is now accessible at https://staging.example.com with a valid SSL certificate, protected by HTTP Basic Authentication.
Step 9: Disable Search Engine Indexing in WordPress
Log into the staging WordPress admin at https://staging.example.com/wp-admin and navigate to:
Settings > Reading > Search engine visibility
Check ✅ Discourage search engines from indexing this site and click Save Changes.
This sets a X-Robots-Tag: noindex header and inserts into all staging pages as a belt-and-suspenders measure alongside HTTP Auth.
Keeping Staging In Sync with Production
After making changes to production content or database, re-sync the staging environment:
You now have a fully isolated, production-identical staging environment that is invisible to search engines, protected from unauthorized access, and ready for safe plugin updates, PHP upgrades, and theme development.
Frequently Asked Questions
A staging environment lets you safely test plugin updates, theme customizations, WooCommerce configurations, and PHP version upgrades without any risk of breaking your live site. Mistakes on a staging site affect zero real visitors — you clone your changes to production only after confirming everything works correctly.
Only if you leave it publicly accessible without protection. By adding HTTP Basic Authentication (via Nginx and htpasswd), the staging subdomain requires a username and password to view. Search engine crawlers cannot authenticate and will not index staging content. Additionally, set Search Engine Visibility to discouraged in WordPress Settings to add a robots noindex directive as a secondary safety net.
Yes. Plugins like WP Staging Pro, Duplicator Pro, and All-in-One WP Migration can automate staging site creation. However, these plugins have file size limits on the free tier and add processing overhead. On a VPS where you have SSH root access, the manual WP-CLI + rsync approach is faster, free, and gives you full control.
The safest method is to use WP-CLI search-replace to update the staging database URLs back to the production domain, then export the staging database with mysqldump and import it into the production database. For theme and plugin file changes, use rsync to overwrite production files from the staging directory, then clear all caches.

Alex Morgan is the founder and lead editor of RemoGrid. With over six years of hands-on experience in remote operations, cross-border freelance workflows, and AI tool benchmarking, Alex independently tests and audits software platforms to help modern digital workers build sustainable online income streams. He regularly reviews international payment systems (Wise, Stripe, Payoneer, local mobile wallets) and conducts real-world usability benchmarks across AI productivity tools.


