Step‑by‑Step Guide to Migrate a WordPress Site to a New Host with Zero Downtime
Step‑by‑Step Guide to Migrate a WordPress Site to a New Host with Zero Downtime
Moving a live WordPress site to a new server can feel risky—any misstep may lead to broken pages, lost SEO juice, or angry visitors. This guide walks you through a reliable, zero‑downtime migration process that keeps your site online, preserves rankings, and avoids data loss.
1. Prepare Your New Environment
Choose a Suitable Hosting Plan
Before you start, make sure the destination server meets the requirements of your WordPress installation (PHP 8+, MySQL 5.7+, sufficient RAM). A lightweight Cloud VPS provides the flexibility you need while keeping costs low.
Set Up the Server Stack
On your new VPS, install a LAMP (or LEMP) stack:
- Update packages:
sudo apt update && sudo apt upgrade -y - Install Nginx or Apache, PHP, and MariaDB.
- Create a dedicated MySQL database and user for WordPress.
Quick‑Tip: Enable the
php-fpmservice and configure Nginx to use it for better performance.
2. Back Up the Existing Site
Export the Database
Log into phpMyAdmin or use WP‑CLI:
wp db export ~/site-backup.sql --add-drop-table
Store the file in a secure location outside the web root.
Copy the Files
Use rsync or an FTP client to download the entire wp‑content folder and the root wp‑config.php file.
Warning: Never skip the
wp‑content/uploadsdirectory—media files are often the biggest source of data loss.
3. Import to the New Server
Create the Database
On the new VPS, run:
mysql -u root -p
CREATE DATABASE new_wp_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'new_wp_user'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON new_wp_db.* TO 'new_wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Import the Dump
Transfer the site-backup.sql file to the VPS and import it:
mysql -u new_wp_user -p new_wp_db < site-backup.sql
Upload WordPress Files
Place the copied wp‑content folder and wp‑config.php into the web root (e.g., /var/www/html). Edit wp‑config.php to reflect the new DB credentials.
4. Test the Migration on a Staging Subdomain
Modify Hosts File
On your local machine, add an entry to point a temporary domain (e.g., staging.example.com) to the new server’s IP. This lets you preview the site without changing public DNS.
Check Permalinks & Plugins
Log into the WordPress admin on the staging URL, go to Settings → Permalinks, and click “Save Changes” to flush rewrite rules. Verify that essential plugins (caching, security) load correctly.
Quick‑Tip: Disable any caching plugins temporarily during testing to avoid stale content.
5. Switch DNS with Zero Downtime
Lower the TTL
One day before the cutover, edit your DNS records and set the TTL (Time‑to‑Live) to a low value, such as 300 seconds. This ensures that DNS changes propagate quickly.
Update the A Record
When you’re confident the new server works, replace the old A record with the IP address of the new VPS. Because the TTL is low, most visitors will resolve to the new server within minutes.
Monitor the Transition
Use tools like WhatsMyDNS to track propagation. Keep the old server running for at least 24 hours as a safety net.
6. Post‑Migration Clean‑Up
Enable Caching & Security
Re‑activate any caching plugins and configure a security plugin (e.g., Wordfence) on the new host. Set up a free Let’s Encrypt SSL certificate to encrypt traffic.
Remove Temporary DNS Entries
After the TTL has expired worldwide and traffic is stable, you can delete the temporary hosts file entry and any staging subdomains.
Warning: Do not delete the old server until you have verified that all backups are intact and the new site functions flawlessly for a full 48‑hour window.
Conclusion
By following these steps—preparing a compatible VPS, backing up meticulously, testing on a staging subdomain, and switching DNS with a low TTL—you can migrate any WordPress site without downtime or data loss. The result is a smoother user experience, preserved SEO rankings, and a fresh hosting environment ready for future growth.