Moving your website to a Hong Kong VPS with CN2 GIA routing — from shared hosting, another VPS, or a cloud provider — can be done with zero visible downtime when planned correctly. The key is running both environments simultaneously, testing thoroughly on the new server before touching DNS, then executing a fast DNS cutover. This guide covers the complete migration process for WordPress, PHP, and Node.js applications.
Migration Checklist Overview
- Provision and configure the new Hong Kong VPS
- Copy files and export database
- Configure the new server (Nginx, PHP-FPM, SSL)
- Import database and update configuration
- Test on the new server using
/etc/hostsoverride - Lower DNS TTL (24 hours before cutover)
- Execute DNS cutover
- Monitor and confirm
- Decommission old server after 48 hours
Step 1: Prepare the New Hong Kong VPS
# On the new Server.HK Hong Kong VPS:
apt update && apt upgrade -y
apt install -y nginx mysql-server php8.3-fpm php8.3-mysql redis-server \
php8.3-redis php8.3-xml php8.3-mbstring php8.3-curl php8.3-zip \
php8.3-gd certbot python3-certbot-nginx git rsync ufw
ufw allow 22/tcp && ufw allow 80/tcp && ufw allow 443/tcp && ufw enable
Step 2: Copy Website Files
From Shared Hosting (via FTP/SFTP)
# Download from old hosting to local machine first
lftp -c "open -u username,password ftp://oldhostname; mirror --parallel=4 /public_html /tmp/site-files"
# Then upload to new VPS
rsync -avz --progress /tmp/site-files/ root@NEW_VPS_IP:/var/www/yourdomain/
From Another VPS (direct rsync)
# Run from the NEW VPS — pull files from old server
rsync -avz --progress --delete \
-e "ssh -p OLD_SSH_PORT" \
root@OLD_VPS_IP:/var/www/yourdomain/ \
/var/www/yourdomain/
# Set correct ownership after sync
chown -R www-data:www-data /var/www/yourdomain
Step 3: Export and Import the Database
MySQL Export (from old server)
# On OLD server — export with consistent snapshot
mysqldump \
--single-transaction \
--quick \
--lock-tables=false \
--routines \
--triggers \
--databases yourdomain_db \
| gzip > /tmp/db_export.sql.gz
# Transfer to new VPS
scp -P NEW_SSH_PORT /tmp/db_export.sql.gz root@NEW_VPS_IP:/tmp/
MySQL Import (on new server)
# On NEW VPS:
mysql -u root -p -e "CREATE DATABASE yourdomain_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -u root -p -e "CREATE USER 'siteuser'@'localhost' IDENTIFIED BY 'StrongPassword!';"
mysql -u root -p -e "GRANT ALL ON yourdomain_db.* TO 'siteuser'@'localhost';"
gunzip -c /tmp/db_export.sql.gz | mysql -u root -p yourdomain_db
# Verify row counts match
mysql -u root -p yourdomain_db -e "SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema='yourdomain_db';"
Step 4: Update Configuration Files
WordPress wp-config.php
# Update database credentials to point to localhost
sed -i "s/DB_HOST.*'.*'/DB_HOST', 'localhost'/" /var/www/yourdomain/wp-config.php
sed -i "s/DB_PASSWORD.*'.*'/DB_PASSWORD', 'StrongPassword!'/" /var/www/yourdomain/wp-config.php
# Update WordPress URLs if server IP differs during testing
mysql -u root -p yourdomain_db -e "
UPDATE wp_options SET option_value='https://yourdomain.com' WHERE option_name='siteurl';
UPDATE wp_options SET option_value='https://yourdomain.com' WHERE option_name='home';
"
Laravel .env
<code">cat > /var/www/yourdomain/.env << 'EOF' APP_ENV=production APP_URL=https://yourdomain.com DB_HOST=127.0.0.1 DB_DATABASE=yourdomain_db DB_USERNAME=siteuser DB_PASSWORD=StrongPassword! REDIS_HOST=127.0.0.1 EOF php artisan config:cache
Step 5: Configure Nginx on New VPS
cat > /etc/nginx/sites-available/yourdomain.com << 'EOF'
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/yourdomain;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
EOF
ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
Step 6: Test on New Server Without Changing DNS
This is the most important step — verify everything works before any user is affected.
# On your LOCAL machine — add a temporary hosts override
# This makes your computer resolve yourdomain.com to the NEW VPS
echo "NEW_VPS_IP yourdomain.com www.yourdomain.com" | sudo tee -a /etc/hosts
# Now browse to https://yourdomain.com in your browser
# You're seeing the new server — not the old one
# Test checklist:
# ✓ Homepage loads correctly
# ✓ Login / registration works
# ✓ Database-driven pages load correctly
# ✓ File uploads work
# ✓ Email sending works (contact forms, etc.)
# ✓ SSL certificate is valid (Let's Encrypt — issue before going live)
# ✓ All media/images load
# ✓ Admin panel accessible
# When done testing, remove the hosts override:
sudo sed -i '/NEW_VPS_IP yourdomain.com/d' /etc/hosts
Issue SSL Certificate (Before DNS Cutover)
<code"># Use webroot mode — old server stays running on port 80 # But new server needs to temporarily answer the ACME challenge # Option 1: Use DNS challenge (no port 80 required) certbot certonly --dns-cloudflare \ --dns-cloudflare-credentials /root/.cloudflare.ini \ -d yourdomain.com -d www.yourdomain.com # Option 2: Set up nginx on new server to answer acme challenge # Then briefly route Let's Encrypt validation to new server via DNS
Step 7: Lower DNS TTL
Do this 24–48 hours before planned cutover:
<code"># In your DNS provider (Cloudflare, Route 53, etc.): # Change TTL for yourdomain.com A record from 3600 → 300 (5 minutes) # This ensures DNS change propagates quickly at cutover time # Verify current TTL dig yourdomain.com +nocmd +noall +answer # Should show current TTL value
Step 8: Final Sync and DNS Cutover
<code"># 1. Do a final rsync to catch any new files uploaded during testing rsync -avz --progress --delete \ -e "ssh -p OLD_SSH_PORT" \ root@OLD_VPS_IP:/var/www/yourdomain/ \ /var/www/yourdomain/ # 2. Export any new database changes (for dynamic sites) # On OLD server: mysqldump --single-transaction yourdomain_db | gzip > /tmp/final_sync.sql.gz scp /tmp/final_sync.sql.gz root@NEW_VPS_IP:/tmp/ # On NEW VPS — import only changed rows or just re-import fresh: gunzip -c /tmp/final_sync.sql.gz | mysql -u root -p yourdomain_db # 3. Change DNS A record to NEW_VPS_IP # In your DNS provider — update yourdomain.com A record from OLD_IP to NEW_VPS_IP # 4. Verify propagation watch -n 5 "dig yourdomain.com +short" # When it shows NEW_VPS_IP, propagation is complete
Step 9: Post-Cutover Monitoring
<code"># Monitor Nginx access log in real-time tail -f /var/log/nginx/access.log | grep -v "200" # Watch error log tail -f /var/log/nginx/error.log # Check PHP-FPM errors tail -f /var/log/php8.3-fpm.log # Database connection test mysql -u siteuser -pStrongPassword! yourdomain_db -e "SELECT COUNT(*) FROM wp_posts;" # Verify SSL curl -sI https://yourdomain.com | head -5
Step 10: Set Up Continuous Sync (Optional Safety Net)
For the first 24–48 hours after cutover, maintain a live rsync from new to old as a rollback-ready backup:
<code"># Run every 5 minutes — syncs new VPS files back to old server as backup crontab -e */5 * * * * rsync -az /var/www/yourdomain/ root@OLD_VPS_IP:/var/www/yourdomain-backup/
Rollback Procedure
If critical issues appear after cutover, rollback to the old server in minutes:
- Change DNS A record back to OLD_VPS_IP (propagates in 5 minutes with 300s TTL)
- Export any data changes from the new VPS and import to old server
- Notify users of temporary maintenance if needed
The 5-minute TTL means rollback is fast and the old server never went fully offline — it just stopped receiving traffic.
Conclusion
A zero-downtime migration to a Hong Kong VPS follows a predictable pattern: sync files and database, configure and test the new server thoroughly using a hosts file override, lower DNS TTL days in advance, then execute the cutover with a final sync. Users experience no interruption — DNS propagation is seamless, and the rollback option remains available for 48 hours.
Start your migration: Browse Server.HK Hong Kong VPS plans — provision your target VPS and complete the migration checklist before pointing a single DNS record.