IPv4 & IPv6 Leasing - Any RIR, Any LocationOrder Now
Hostperl

WordPress Staging to Production Cutover on Ubuntu 24.04

By Raman Kumar

Share:

Updated on Dec 5, 2026

WordPress Staging to Production Cutover on Ubuntu 24.04

What this WordPress staging to production cutover guide solves

Use this tutorial when your WordPress site is already built on staging and you need a clean production cutover on Ubuntu 24.04. You will create a non-root admin, sync files and database content, replace staging URLs safely, switch DNS or web-root content, and verify the live site end to end.

This workflow fits agencies, small businesses, and ecommerce teams moving a site from review to launch on Hostperl VPS hosting. If your site is more than a brochure build, the final steps matter just as much as the first install.

ssh root@203.0.113.10

Run this on your local computer. 203.0.113.10 is a documentation example, so replace it with the real public IP from your hosting provider. If your provider gives you a default non-root account, you can use that instead, but still connect first from your local computer.

Confirm the server is Ubuntu 24.04

cat /etc/os-release

Run this on the VPS as root. You should see Ubuntu 24.04 in the output. This tutorial is written for Ubuntu Server because it is the least-covered OS track in this rotation and it supports the exact toolchain used here: apt, systemd, UFW, AppArmor, and standard WordPress hosting packages.

Create a sudo user before you change anything

Keep the root session open. Create the day-to-day admin account first, then test it in a second terminal before you lock down root access.

adduser deploy

Run this on the VPS as root. Replace deploy only if you are using a different administrator name. Set a strong password when prompted.

usermod -aG sudo deploy

This adds the new account to the sudo group. On Ubuntu, that is the standard administrative path.

mkdir -p /home/deploy/.ssh

Copy your public key into the new account. From your local computer, use:

ssh-copy-id deploy@203.0.113.10

If your key is already managed another way, make sure /home/deploy/.ssh/authorized_keys exists and is owned by deploy:deploy.

chown -R deploy:deploy /home/deploy/.ssh
chmod 700 /home/deploy/.ssh
chmod 600 /home/deploy/.ssh/authorized_keys

Open a second terminal and test the new login from your local computer:

ssh deploy@203.0.113.10

Then confirm sudo works on the VPS as the non-root sudo user:

sudo -v

You should be prompted for the deploy password and then returned to the shell without an error.

Update packages and install the WordPress cutover tools

These commands install the tooling you need for a controlled migration: rsync, MariaDB client utilities, and the WordPress CLI. If WP-CLI is already installed on your build host, keep the version you have, but make sure it is current enough for safe search-and-replace operations.

sudo apt update
sudo apt install -y rsync mariadb-client curl unzip

Install WP-CLI on the VPS as the non-root sudo user:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info

If the php command is missing, install PHP first with the version your WordPress stack uses. For most Ubuntu 24.04 WordPress hosts, that is PHP 8.3.

Prepare the production document root

In a typical Hostperl VPS deployment, WordPress lives under /var/www/example.com or a similar site root. Replace the example domain with your real domain. If your site root is already set, skip the directory creation and use the existing path consistently.

sudo mkdir -p /var/www/example.com
sudo chown -R deploy:www-data /var/www/example.com
sudo chmod -R 750 /var/www/example.com

The ownership pattern keeps deploy in control while allowing the web server group to read the content.

Back up staging before you touch live data

A cutover is only safe if you can roll back. Back up both files and the database dump before the switch.

mkdir -p ~/cutover-backups
rsync -aHAX --delete /var/www/staging-site/ ~/cutover-backups/staging-files/

Replace /var/www/staging-site/ with your actual staging path. The --delete flag mirrors the source exactly, so do not point it at the wrong directory.

mariadb-dump -u wordpress -p --single-transaction --routines --triggers wordpress_db > ~/cutover-backups/staging-db.sql

Replace wordpress and wordpress_db with your real database user and database name. The dump should complete without warnings.

Sync WordPress files from staging to production

Use rsync for the final file sync because it preserves ownership, permissions, timestamps, and symlinks. That matters when plugins, uploads, and cache directories are part of the move.

rsync -aHAX --delete --exclude='wp-config.php' /var/www/staging-site/ /var/www/example.com/

This command copies the site files while leaving the production wp-config.php in place if it already contains live credentials. If production has no config yet, copy it manually and edit it in the next step.

For agencies and teams moving multiple client sites, Hostperl’s WordPress migration cutover without checkout downtime guide is a useful companion when the site is ecommerce-heavy.

Set production credentials and lock down wp-config.php

Edit the config file with your live database settings and the correct site URLs. Use a real editor, not a one-line replace, so you can review the values before saving.

nano /var/www/example.com/wp-config.php

Inside the file, make sure the database block matches production:

define( 'DB_NAME', 'wordpress_prod' );
define( 'DB_USER', 'wordpress_user' );
define( 'DB_PASSWORD', 'strong_password_here' );
define( 'DB_HOST', 'localhost' );

Save and exit with Ctrl+O, Enter, then Ctrl+X.

Protect the file so only the right account can read it:

sudo chown root:www-data /var/www/example.com/wp-config.php
sudo chmod 640 /var/www/example.com/wp-config.php

That keeps secrets out of casual view while still allowing PHP-FPM or Apache to read the file through the web-server group.

Replace staging URLs safely

WordPress stores URLs in serialized data, so do not use a blind database UPDATE unless you are prepared to repair broken serialization. WP-CLI handles this correctly.

cd /var/www/example.com
php ~/wp-cli.phar search-replace 'https://staging.example.com' 'https://example.com' --all-tables --precise --recurse-objects --skip-columns=guid

Replace the staging and production URLs with your real values. You should see a summary of changed rows, not a fatal database error.

If your site uses a nonstandard domain mapping or a reverse proxy, compare this with the URL-handling notes in answer-first hosting pages that AI can quote in 2026 to keep the visible site structure clear for both users and search engines.

Run a database sanity check

Before you switch traffic, check that the production database can be queried and that the tables are present.

php ~/wp-cli.phar db check

You should get a clean response. If WP-CLI reports a socket or permission error, verify the credentials in wp-config.php and ensure MariaDB is running.

Harden the web root and enable the firewall

Open only the ports you actually use. On a standard Ubuntu WordPress server, that is usually SSH, HTTP, and HTTPS.

sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable

If you use Apache instead of Nginx, allow the Apache profile instead. Do not enable the firewall before you allow SSH or you may lock yourself out.

For WordPress sites that rely on tighter account separation, the file and account behavior described in cPanel account isolation on AlmaLinux 9 for agencies shows why ownership and permissions matter even outside cPanel.

Reload services and check syntax first

Always test configuration files before you reload a live service.

sudo nginx -t

If you use Apache instead, run sudo apache2ctl configtest. A successful Nginx test ends with syntax is ok and test is successful.

sudo systemctl reload nginx

Then check the service state:

systemctl status nginx --no-pager

You should see active (running).

Verify the live site from the server and a client

From the VPS as the non-root sudo user, confirm the site responds locally:

curl -I https://example.com

Replace the domain with your production hostname. A healthy response is usually 200 OK or 301 Moved Permanently if you are redirecting HTTP to HTTPS.

Check the WordPress front page and a login page from your local computer too:

curl -I https://example.com/wp-login.php

You want a valid HTTP response, not a DNS failure, TLS error, or 5xx code.

If the site is ecommerce-focused, validate a real checkout flow after the cutover. Hostperl’s WordPress checkout stability on Hostperl VPS in 2026 explains the operational risks that show up after deployment, not just during it.

Roll back cleanly if something fails

If the live site breaks after the move, restore in the reverse order you used for the cutover. First, put the previous files back, then restore the database dump, then reload the web service.

rsync -aHAX --delete ~/cutover-backups/staging-files/ /var/www/example.com/
mariadb -u wordpress -p wordpress_prod < ~/cutover-backups/staging-db.sql

After rollback, rerun the same URL checks and confirm the site matches the pre-cutover state. Keep the backup files until the launch window is fully closed.

Troubleshooting the most likely failures

1. The site shows a database connection error. Run:

sudo tail -n 50 /var/log/mysql/error.log

If the log shows access denied or unknown database, fix the values in wp-config.php and test again with php ~/wp-cli.phar db check.

2. WordPress redirects to the staging domain. Run:

php ~/wp-cli.phar option get home && php ~/wp-cli.phar option get siteurl

If either value still points to staging, update it with php ~/wp-cli.phar option update home https://example.com and php ~/wp-cli.phar option update siteurl https://example.com.

3. Permissions break uploads or plugin updates. Run:

ls -ld /var/www/example.com /var/www/example.com/wp-content /var/www/example.com/wp-content/uploads

If ownership is wrong, correct it with sudo chown -R deploy:www-data /var/www/example.com and retest a media upload.

4. Nginx will not reload. Run:

sudo nginx -t

The error message usually points to the exact bad directive or missing file. Fix that file first, then reload again.

Confirm reboot persistence

Before you close the maintenance window, make sure the stack comes back after a reboot. This prevents a false sense of success on launch day.

systemctl is-enabled nginx
systemctl is-enabled mariadb

Each service should report enabled. If one is disabled, enable it with sudo systemctl enable nginx mariadb and test again after a controlled reboot.

If you are moving a staging build into production, Hostperl can give you the VPS headroom, support response, and migration-friendly setup that lowers cutover risk. For WordPress launches that need clean resource allocation, start with Hostperl VPS hosting and keep a rollback path ready before traffic changes.

For business sites that need stronger isolation or steadier performance under load, compare that with dedicated server hosting when your workload outgrows a small VPS.

FAQ

Can I do this cutover without downtime?
Yes, if you freeze content edits briefly, sync files, run the database search-replace, and switch traffic during a short maintenance window.

Should I use rsync or a plugin for migration?
For production cutovers, rsync plus WP-CLI gives you better control, clearer rollback, and fewer surprises than a plugin-only move.

What if my production site uses HTTPS only?
Use the live HTTPS URL in the search-replace command and make sure your certificate is already installed before the switch.

Can I reuse the staging database on production?
Only after you back it up and confirm it contains the live data you expect. Always treat the database as the most sensitive part of the move.

What is the safest final check?
Open the homepage, login page, and one real customer path such as checkout or form submission, then confirm the server logs stay clean.