A dedicated development or staging VPS lets you test changes in an environment that closely mirrors production, without risking your live site. This guide covers setting one up effectively.
Why Use a Separate Dev/Staging VPS
- Test changes safely without affecting production users
- Catch environment-specific bugs before they reach production
- Allow team members to collaborate on features without conflicting with each other
- Test infrastructure changes (new software versions, configuration) risk-free
Recommended Specs for a Dev/Staging VPS
Generally smaller than production is acceptable, since it doesn't need to handle real user traffic — 2 vCPU, 2–4 GB RAM is often sufficient for most development purposes.
Step 1 — Mirror Your Production Stack
Install the same OS, web server, database engine, and runtime versions as production — this is the entire point of a staging environment, and mismatched versions defeat its purpose.
Step 2 — Set Up Git-Based Deployment
Configure a simple deployment workflow so pushing to a specific branch (e.g. staging) automatically updates the staging environment:
cd /var/www/staging
git pull origin staging
This can be automated via a simple webhook or CI/CD pipeline for a smoother workflow.
Step 3 — Use a Separate Database
Never point staging at your production database directly — use a separate database, optionally seeded with anonymized production-like data for realistic testing.
Step 4 — Password-Protect or Restrict Access
Staging environments shouldn't be publicly indexed or accessible. Options:
- HTTP Basic Auth at the Nginx/Apache level
- Restrict access by IP at the firewall — see How to Configure UFW Firewall on a Linux VPS
- Add a
noindexmeta tag orrobots.txtdisallow to prevent search engine indexing
Basic Auth Example (Nginx)
sudo apt install apache2-utils -y
sudo htpasswd -c /etc/nginx/.htpasswd staginguser
location / {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
Step 5 — Enable Verbose Logging/Debugging
Unlike production, staging is the appropriate place to enable debug modes, verbose logging, and detailed error pages to help catch issues before they reach real users.
Using Docker for Consistent Dev Environments
Docker Compose is particularly well-suited for development environments, since it can spin up your entire stack (app, database, cache) with one command, and easily be torn down and recreated — see How to Install Docker Compose on Ubuntu & Debian.
Syncing Staging Closer to Production Periodically
Periodically refresh staging's database from a sanitized production backup to keep testing realistic, being careful to strip or anonymize any genuinely sensitive customer data first.
Common Errors
"Works on staging, breaks on production" — usually indicates a configuration or environment variable difference; audit both environments for drift.
Staging accidentally publicly accessible and indexed — add access restrictions immediately (Basic Auth or IP restriction) and add noindex directives.
Ready to put this into practice? Explore VPS For Life's hosting plans to find the right fit for your project, or talk to our team if you're not sure where to start.
Continue Reading
- How to Install Docker Compose on Ubuntu & Debian
- How to Configure UFW Firewall on a Linux VPS
- How to Migrate a Database to a New VPS
Browse more articles in Use Cases & Buyer Guides.
