How to Migrate a WordPress Site from Shared Hosting to a VPS

Shared hosting is a fine place to start, but it stops being fine the moment your site outgrows it: traffic spikes that get throttled, PHP versions you cannot change, and server-level caching that stays out of reach. Moving to a VPS puts you in full control, but the migration itself makes most site owners nervous. The good news is that a WordPress migration is a fixed sequence of steps, and if you follow them in order, your visitors will not notice a thing: back up everything, prepare the new server, move the files and database, test before touching DNS, then switch over.

What you need before you start

Gather these four things first so you are not hunting for logins mid-migration:

  • A VPS with root SSH access (size it to your traffic; check official pricing before ordering)
  • A LEMP or LAMP stack installed on the VPS
  • Access to your domain’s DNS settings
  • Your shared hosting control panel (cPanel, DirectAdmin, or similar)

Step 1: Back up the shared hosting site

A WordPress site is two things: the files (themes, plugins, uploads) and the database (posts, settings, users). You need both, and a backup of only one is the same as no backup.

If your shared host gives you SSH access (many enable it on request), run these two commands in your home directory:

cd ~/public_html
tar -czf ~/site-backup.tar.gz .
mysqldump -u yourdbuser -p yourdbname > ~/db-backup.sql

Then download both files to your local machine over SFTP.

No SSH? Use cPanel: open File Manager, select public_html, and compress it; then open phpMyAdmin, select your database, and Export it (the Quick method is fine). Download both files.

Finally, open wp-config.php and write down the database name, database user, and password. You will need these exact values later.

Step 2: Set up the VPS

On a fresh Ubuntu server, install a LEMP stack. Match the PHP version to what your site already runs: check the PHP selector in your shared hosting panel first, because a plugin that worked on PHP 8.1 can white-screen on 8.3, and that is a self-inflicted problem you do not want during a migration.

sudo apt update && sudo apt install -y nginx mariadb-server php8.2-fpm php8.2-mysql php8.2-curl php8.2-xml php8.2-mbstring

Create the database and a dedicated user for the site:

sudo mysql
CREATE DATABASE wpdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER ‘wpuser’@’localhost’ IDENTIFIED BY ‘a-strong-password’;
GRANT ALL PRIVILEGES ON wpdb.* TO ‘wpuser’@’localhost’;
FLUSH PRIVILEGES;
EXIT;

Create an Nginx server block pointing at /var/www/yoursite.com with PHP-FPM as the handler. If you have never written an Nginx vhost before, copy your distro’s default, change server_name and root, and include the standard WordPress permalink rule:

try_files $uri $uri/ /index.php?$args;

Step 3: Move the files and the database

Upload your backup to the VPS. From your local machine, scp works fine:

scp site-backup.tar.gz db-backup.sql root@YOUR_VPS_IP:/var/www/yoursite.com/

Extract the archive, then fix ownership so Nginx and PHP-FPM can read everything:

cd /var/www/yoursite.com
tar -xzf site-backup.tar.gz
sudo chown -R www-data:www-data .
sudo find . -type d -exec chmod 755 {} ;
sudo find . -type f -exec chmod 644 {} ;

Import the database and point wp-config.php at the new credentials:

mysql -u wpuser -p wpdb < db-backup.sql

Edit wp-config.php: set DB_NAME to wpdb, DB_USER to wpuser, and DB_PASSWORD to the password you created. If the domain itself is changing (unusual for this kind of move), install wp-cli on the VPS and run wp search-replace on the old and new domains afterward.

Step 4: Test the site before touching DNS

This is the step people skip, and skipping it is how you end up with a day of downtime. Point your own computer at the new server without changing public DNS: add one line to your local hosts file (/etc/hosts on Linux/Mac, C:WindowsSystem32driversetchosts on Windows):

YOUR_VPS_IP   yoursite.com www.yoursite.com

Now browse the site normally. Check the homepage, a few posts, the images, and the wp-admin login. Click around. Broken images or a database error here mean something went wrong in step 3: wrong database credentials, a failed import, or wrong file ownership. Fix it now, while only you can see the breakage. Remove the hosts entry when testing is done.

Step 5: Switch DNS and go live

A day before the switch, lower the TTL on your A record to 300 seconds so the change spreads fast. Then update the A record (and www) to your VPS IP and delete the old shared hosting records.

Install SSL right away. Once the domain points at the VPS, Certbot does it in one command:

sudo certbot –nginx -d yoursite.com -d www.yoursite.com

Verify with dig yoursite.com or an online DNS checker that the world now sees the new IP, then raise the TTL back up. Keep the shared hosting account for a week or two as a fallback before cancelling it.

Common problems after a WordPress VPS migration

Symptom Cause Fix
Mixed content warnings Site loads over HTTPS but images or styles still use HTTP Run a search-replace of http://yoursite.com to https://yoursite.com in the database
Email stops working Shared hosts often run your mailboxes too Move email to your domain provider or a mail service and update MX records before cancelling the old host
Permalink 404 errors Nginx ignores .htaccess Make sure try_files $uri $uri/ /index.php?$args; is in the server block
White screen after the move PHP version mismatch Install the same PHP version the shared host used, then upgrade plugins carefully
Scheduled tasks disappear Cron jobs lived on the old server Copy the cron list from the shared host and recreate backup scripts or wp-cron triggers on the VPS

The takeaway

A WordPress migration is not a creative project; it is a checklist: backup, new server, transfer, test, DNS. The test-before-DNS step is the one that separates a boring, uneventful migration from a stressful one. Once the new site is live and stable, you own the full stack: pick your PHP version, add Redis object caching, tune Nginx, and never get throttled by a neighbor’s traffic spike again. Not sure the new box is big enough for everything you plan to run? Our VPS sizing guide for self-hosting works through the numbers.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.