Moving WordPress from shared hosting (or another server) to a VPS is mostly copying two things — the files and the database — and switching DNS. Done in the right order, visitors never see downtime and you can test everything before the switch.
Overview
- Lower the DNS TTL (a day ahead).
- Prepare the new server.
- Copy files and database.
- Test the new server privately via your hosts file.
- Final sync, switch DNS.
- Verify and clean up.
1. Lower the DNS TTL in advance
At your DNS provider, set the TTL of the domain’s A (and AAAA) records to 300 seconds (5 minutes), at least one old-TTL period before the move — often 24 hours. Then the switch propagates quickly. See DNS propagation and TTLs.
2. Prepare the VPS
Install the stack — Nginx, PHP-FPM (same or newer PHP version than the old host, with the same extensions), MariaDB/MySQL, Certbot. Follow installing WordPress on Ubuntu with Nginx up to (but not including) downloading WordPress, and create an empty database and user.
Check the PHP version and extensions the site needs on the old host (Tools → Site Health → Info → Server).
3. Copy the files
If you have SSH on the old host
# on the new VPS
rsync -avz --progress [email protected]:public_html/ /var/www/example.com/
See rsync examples.
Without SSH
Download a zip of public_html via the old host’s file manager (or SFTP), upload it with scp and extract it into /var/www/example.com/.
Then set ownership:
sudo chown -R www-data:www-data /var/www/example.com
4. Copy the database
Export on the old host — via SSH:
mysqldump --single-transaction -u olduser -p old_db | gzip > wp.sql.gz
…or with phpMyAdmin’s Export (SQL format). Import on the VPS:
gunzip < wp.sql.gz | sudo mysql wordpress
Update wp-config.php with the new database name, user and password, and set DB_HOST to localhost. Shared hosts often use a remote DB host or prefixed names.
Check the table prefix ($table_prefix) matches the imported tables (SHOW TABLES;).
5. Fix things that differ between hosts
- Absolute paths: some plugins store server paths (e.g.
/home/user/public_html). Search and replace them:
cd /var/www/example.com
sudo -u www-data wp search-replace '/home/olduser/public_html' '/var/www/example.com' --all-tables --dry-run
.htaccessrules: Nginx ignores.htaccess. Rewrite essential rules (redirects, security rules from plugins) as Nginx config. WordPress permalinks need only the standardtry_filesline.- Caching plugins may have written Apache-specific config or absolute paths — reconfigure or re-save their settings after the move.
- Cron: set up system cron if the old host did — see WordPress real cron.
- Email: shared hosts often send mail via local
sendmail; on a VPS configure SMTP — see WordPress SMTP.
6. Test before switching DNS
On your computer, point the domain at the new server by editing the hosts file:
- Linux/macOS:
/etc/hosts - Windows:
C:\Windows\System32\drivers\etc\hosts
203.0.113.10 example.com www.example.com
Now your browser goes to the VPS while everyone else still sees the old site. Test thoroughly: homepage, posts, images, login, forms, checkout.
HTTPS before DNS: Let’s Encrypt can’t validate via HTTP until DNS points to the VPS. Options: test over HTTP first, use a DNS-01 challenge (wildcard/DNS guide), or temporarily copy the old site’s certificate. Or test with curl: curl -I --resolve example.com:443:203.0.113.10 https://example.com once a certificate exists.
7. Final sync and switch
To avoid losing comments, orders or posts created during testing:
- Put the old site in maintenance mode (or pause changes).
- Re-sync uploads: run the same rsync again (only changes transfer).
- Re-export and import the database.
- Change the DNS A record to the VPS IP.
- Remove your hosts-file entry.
For busy WooCommerce stores, schedule this in a quiet hour.
8. After the switch
- Issue the certificate:
sudo certbot --nginx -d example.com -d www.example.com. - Watch logs:
sudo tail -f /var/log/nginx/error.log. - Check from several networks that the new IP is served (
dig +short example.com @1.1.1.1). - Set up backups and monitoring on the new server.
- Keep the old hosting for a week as a fallback, then cancel it. Raise the DNS TTL back up.
Plugin-based migration
Plugins like Duplicator, All-in-One WP Migration or Migrate Guru bundle everything into one package. They’re convenient for small sites, but large sites often hit upload or time limits. The manual method above works for any size and gives you full control.
Troubleshooting
- Error establishing a database connection — check credentials and
DB_HOST— see the fix. - Redirects to the old URL —
siteurl/homeinwp_optionsdiffer; see changing the site URL. - Images missing —
wp-content/uploadsdidn’t copy completely, or permissions. - 404 on all pages except the homepage — Nginx
try_filesmissing — see permalinks 404.
Moving more than one site? Our WordPress VPS page explains plan sizes for multiple WordPress sites, and the 7-day money-back guarantee lets you test the move risk-free.