Set Up a WordPress Staging Site on Hostinger and Deploy Changes

by Fahim

Pushing plugin updates or refactored theme code straight to your live site is asking for an outage. We’re setting up an isolated staging environment on Hostinger using hPanel and WP-CLI so you can test breaking changes and push code back without trashing live database rows.

Most staging guides tell you to click one button in your hosting panel, test your update, and click another button to deploy. That’s fine on a static brochure site with zero traffic. But on an active site with incoming WooCommerce orders, blog comments, or user registrations? Clicking a generic “push to live” button completely overwrites your production database with days-old data from staging. I learned this the hard way after wiping out forty-six checkout transactions during a theme redesign.

Here is the full lifecycle: provisioning the subdomain, locking it down from search engines and scrapers, handling database syncs with wp-cli, and deploying updates safely.

Terminal screen showing WP-CLI search-replace and rsync commands for WordPress staging deployment on Hostinger
Terminal screen showing WP-CLI search-replace and rsync commands for WordPress staging deployment on Hostinger

The Real Danger of One-Click Staging Deployments

Hostinger includes a built-in staging tool under the WordPress section of hPanel on Business and Cloud plans. When you click “Create Staging,” Hostinger spins up a subfolder in your account, copies your entire file structure, clones the MySQL database into a new schema, and replaces the domain strings.

The trap is deploying back to production. Hostinger gives you a tempting “Publish” button inside hPanel. When you hit Publish, it runs a blind overwrite of production files and the database. If your staging environment sat around for three days while you debugged a WooCommerce patch, every single order, user registration, and comment placed on live during those three days gets vaporized.

Knowing what lives in the filesystem versus what lives in the database is what keeps you from breaking things:

  • Code changes: PHP files, CSS, JavaScript, child themes, and plugin folders live in wp-content. You can sync these directly without touching tables.
  • Content additions: Blog posts, products, and customer orders live in the database (wp_posts, wp_postmeta, wp_comments). These should always be authored on production, not staging.
  • Configuration changes: Theme customizer values, plugin settings, and API keys sit in wp_options. These need manual migration or selective SQL imports.

Treat deployments as an all-or-nothing overwrite, and you’ll eventually drop data. Let’s spin up the staging environment the right way first.

Provisioning Staging in Hostinger hPanel

Head to your Hostinger hPanel dashboard and go to Websites. Find your production domain and click Manage.

In the left sidebar, open the WordPress menu and hit Staging. If you’re on Business Web Hosting or higher, you’ll see the staging interface. On Single or Premium shared plans, this menu isn’t available—you’ll need to manually set up a subdomain and database, or bump your tier.

Click Create Staging. Hostinger asks for a subdomain prefix. I usually stick with something simple like staging or dev.

Click Create. The background script takes anywhere from 45 to 90 seconds depending on how bloated your site is. Under the hood, Hostinger runs three steps:

  1. Creates a directory at /home/u123456789/domains/example.com/public_html/staging (or a dedicated root subdomain folder, depending on how your account is organized).
  2. Dumps your live MySQL database, imports it into a new database prefixed with u123456789_stg, and writes the new credentials into wp-config.php.
  3. Runs an automated search-and-replace on your site URL options across the cloned tables.

Once the spinner finishes, your staging site lives at https://staging.example.com. Don’t start clicking around just yet—you need to check SSL and lock it down first.

Fixing Staging SSL and Locking Out Search Engines

Fresh staging subdomains frequently hit an ERR_SSL_PROTOCOL_ERROR or throw certificate mismatch warnings in Chrome. This happens when the wildcard certificate doesn’t automatically issue for the new subdomain right away.

If you get an insecure connection error, check our guide on how to fix SSL certificate errors on a subdomain in Hostinger to reissue the Let’s Encrypt cert from hPanel before doing anything else.

Next: lock Google and random crawlers out. Hostinger checks the “Discourage search engines from indexing this site” checkbox in WordPress reading settings, but meta tags are useless against aggressive scrapers. Canonical issues can still hurt your live rankings.

We’ll lock the entire site behind HTTP Basic Authentication via .htaccess. SSH into your Hostinger account or use the hPanel File Manager, hop into your staging root directory, and generate a .htpasswd file.

Generate a password hash on your local machine using OpenSSL:

# Generate an encrypted password for user 'developer' using openssl
openssl passwd -apr1 "MySuperSecurePassword123!"

You’ll get an Apache-compatible MD5 hash like $apr1$ab12cd34$v5K9wZ5jP8xLmN7qR2sT4.. Create the .htpasswd file one level above your public root so nobody can download it through a browser:

# Store credentials in a non-public directory
nano /home/u123456789/.htpasswd_staging

Paste in your username and hash:

developer:$apr1$ab12cd34$v5K9wZ5jP8xLmN7qR2sT4.

Next, edit the .htaccess file inside your staging WordPress root folder. Paste this block right at the top, before # BEGIN WordPress:

AuthType Basic
AuthName "Staging Environment - Private Access"
AuthUserFile /home/u123456789/.htpasswd_staging
Require valid-user

Save it. Load https://staging.example.com in an incognito tab, and your browser should immediately prompt for HTTP credentials. Googlebot gets hit with a 401 Unauthorized and bails immediately, keeping your live search rank safe.

Setting Up SSH Access and Connecting with WP-CLI

Running staging exclusively through /wp-admin is painful. One fatal error in a plugin and you’re locked out of the dashboard anyway. SSH gives you direct access to WP-CLI, which comes pre-installed on all Hostinger shared and cloud plans.

To enable SSH, open hPanel, head to Advanced > SSH Access, and toggle it to Enabled. Grab your SSH IP, port (Hostinger runs on port 65002, not standard 22), and username.

Connect from your terminal:

# Connect to Hostinger via non-standard port 65002
ssh -p 65002 u123456789@195.154.120.45

Once you’re in, navigate to your staging root. On Hostinger, the path usually looks like this:

# Navigate to staging directory
cd /home/u123456789/domains/example.com/public_html/staging # Verify wp-cli works and matches the staging site URL
wp option get siteurl

If that returns https://staging.example.com, you’re in the right spot. Make sure staging has enough memory allocated before you run heavy updates so scripts don’t die mid-execution. If you run into memory limits, see how to increase the PHP memory limit in WordPress on Hostinger to raise your limit to 512MB.

Testing Code, Plugins, and Database Migrations

With staging locked down and accessible via CLI, you can actually test things safely. Here is how I test core, plugins, and custom code.

First, turn on verbose WordPress error logging on staging. Open wp-config.php in your staging root:

// Enable debug logging on staging
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);

This dumps all notices, warnings, and unhandled fatal errors into /wp-content/debug.log without showing raw stack traces to users. Tail the log in real time while clicking through your pages:

# Tail the debug log during testing
tail -f wp-content/debug.log

Update your plugins one at a time using WP-CLI. Bulk-updating everything at once makes it impossible to pinpoint which plugin broke your cart:

# Check pending plugin updates
wp plugin list --update=available # Update WooCommerce individually
wp plugin update woocommerce # Check database migration status if required
wp wc update

Heavy plugins like WooCommerce or Elementor often run background database migrations during updates. Click through your critical user flows: add items to cart, run a test checkout, submit forms, log in as a standard user. If something fails, you’ll catch the exact file and line number right in your debug.log stream.

If staging feels slow, LiteSpeed Cache might need tuning. If you want to compare load times with production, check out our guide on how to reduce WordPress TTFB on Hostinger with LiteSpeed Cache so object caching behaves the same on both environments.

The Gotcha: Serialized Data and Hostinger URL Replacement

Here’s a nasty bug I ran into pushing database tables back to production manually: missing widgets and completely broken theme layouts.

WordPress stores theme customizer settings, Elementor layouts, and widget options inside wp_options as serialized PHP strings. A serialized string includes explicit character length counters:

// Example of serialized PHP array in wp_options
s:27:"https://staging.example.com";

Notice the length is explicitly defined as 27. If you run a naive SQL REPLACE() query in phpMyAdmin to swap https://staging.example.com with https://example.com (length 19), that length header stays stuck at 27. PHP fails to unserialize the string, returns false, and WordPress drops your entire layout.

Never run raw SQL search-and-replace queries on WordPress databases. If you must sync database tables manually, always use wp search-replace via the command line—it recalculates string lengths properly:

# Test replacement with a dry run first
wp search-replace 'https://staging.example.com' 'https://example.com' --dry-run
# If replacements look valid, run on specific tables only
wp search-replace 'https://staging.example.com' 'https://example.com' wp_options wp_postmeta --precise --recurse-objects

The --precise flag makes sure multibyte characters don’t throw off string offsets. It will save you hours of hunting down disappearing page builder blocks.

How to Deploy Changes to Production Safely

You’ve tested your updates on staging and debug.log is clean. Time to ship. Pick one of these two approaches based on what you actually changed.

Method 1: Code-Only Deployments (Plugins, Themes, Child Theme Code)

If your changes are strictly plugin updates, tweaks to your child theme’s functions.php, or CSS/JS updates, do not touch the database. Leave production tables alone.

Connect over SSH and use rsync to pull tested files from staging straight into production. Zero risk to live orders:

# Define staging and production paths
STAGING_DIR="/home/u123456789/domains/example.com/public_html/staging"
PROD_DIR="/home/u123456789/domains/example.com/public_html" # Sync child theme changes safely without deleting production uploads
rsync -avz --exclude 'uploads'  $STAGING_DIR/wp-content/themes/my-child-theme/  $PROD_DIR/wp-content/themes/my-child-theme/

For plugins, you can run the exact same wp plugin update command directly on production via SSH, or sync the plugin folder over with rsync:

# Run the tested plugin update on production
cd /home/u123456789/domains/example.com/public_html
wp plugin update woocommerce --version=8.5.1

Since you already validated this exact release on staging, you know it won’t throw an unhandled fatal error on live.

Method 2: Full Deployment (When hPanel “Publish” Is Safe)

You should only use Hostinger’s built-in “Publish” button under WordPress > Staging if your site meets all three rules:

  • It is a brochure site, portfolio, or static blog where visitors never submit data.
  • No one authored new posts, products, or pages on production while you were working on staging.
  • You take an on-demand backup right before clicking the button.

Before you hit Publish in hPanel, make a manual backup. Go to Files > Backups in hPanel and click Create a new backup. It takes around two minutes and gives you a clean restore point if things go sideways.

Now jump back to WordPress > Staging, find your staging site, and click Publish. Hostinger will show a confirmation modal warning that production data will be overwritten. Confirm it.

Right after deploying, purge your cache. Hostinger runs on LiteSpeed Web Server, so you can flush it instantly from the CLI:

# Flush LiteSpeed cache on production
cd /home/u123456789/domains/example.com/public_html
wp litespeed-purge all

Scheduled tasks can also stall out after deployments. If background jobs hang, set up a real cron job using our tutorial on how to replace WP-Cron with a real system cron job on Hostinger so your background queue runs reliably.

Troubleshooting Common Hostinger Staging Issues

Here are three snags that come up constantly when managing staging environments on Hostinger, and how to fix them.

1. Infinite Redirect Loops on Staging

You visit https://staging.example.com and get hit with ERR_TOO_MANY_REDIRECTS. This almost always means hardcoded URLs inside wp-config.php are fighting the database options.

Check your staging wp-config.php for these constants:

// If these point to your production URL, staging will loop endlessly
define('WP_HOME', 'https://example.com');
define('WP_SITEURL', 'https://example.com');

Change them to point to your staging subdomain:

// Correct values for the staging environment
define('WP_HOME', 'https://staging.example.com');
define('WP_SITEURL', 'https://staging.example.com');

2. Broken Images After Migration

If your staging site shows broken image placeholders, inspect the asset URLs in DevTools. Staging clones usually copy the entire wp-content/uploads folder. If you’re short on disk space, Hostinger might fail to clone a massive media library completely.

Instead of duplicating gigabytes of images, proxy missing files back to production with an .htaccess rewrite rule in your staging root:

# Proxy missing staging media to production server
 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} ^/wp-content/uploads/(.*)$ [NC] RewriteRule ^wp-content/uploads/(.*)$ https://example.com/wp-content/uploads/$1 [L,R=302]

Your staging site can now pull images directly from production on the fly without duplicating 20GB of media onto your hosting disk.

3. Elementor Styling Stripped on Staging

If staging loads unstyled text and missing fonts after a sync, Elementor’s generated CSS cache is still pointing to your old URLs or missing file paths. Log into staging WP admin, go to Elementor > Tools, and click Regenerate CSS & Data. Or run it in one second via WP-CLI:

# Flush Elementor CSS generation
wp elementor flush_css

Frequently Asked Questions

Can I create more than one staging site on Hostinger?

Hostinger’s built-in staging tool allows one active staging environment per WordPress installation on Business Web Hosting plans, while Cloud Hosting plans allow multiple. If you need several staging environments (like feat-cart and dev) on a standard plan, you can manually configure subdomains, clone your folders, and hook them up to separate databases.

Does a staging site consume my Hostinger plan’s disk quota?

Yes. A staging site duplicates your files and database. If your production site uses 8GB of disk space and a 500MB database, spinning up staging immediately eats another 8.5GB of your total SSD storage. Keep an eye on disk usage inside hPanel’s resource graph.

Why are emails sending from my staging site?

When you clone production to staging, plugins like WooCommerce, form builders, and CRM add-ons bring their live API keys and mail settings along with them. If you test a checkout, the staging site will gladly fire real confirmation emails to real customers. Install a plugin like WP Mail Catcher or configure a dummy SMTP host in wp-config.php on staging to catch outbound mail.

How do I delete a staging site in Hostinger?

To wipe a staging site, open hPanel, head to WordPress > Staging, click the three-dots menu next to your staging instance, and choose Delete. Hostinger drops the staging database and deletes the staging subfolder automatically, freeing up your disk space.

Next Steps for Your Deployment Workflow

Now that your staging site is isolated and password-protected, bake it into your normal update routine. Never trigger an untested plugin or core update directly on production.

If testing reveals sluggish dashboard performance or long execution times, check our walkthrough on how to increase the PHP memory limit in WordPress on Hostinger so your server has the headroom it needs for resource-heavy operations.

Official resources

all_in_one_marketing_tool