How to Migrate from Shared Hosting to VPS: A Step-by-Step Guide

We earn commissions when you shop through the links below.

If you’ve been running a site on shared hosting and you’re hitting performance walls, getting throttled on resources, or just want more control over your stack, knowing how to migrate from shared hosting to VPS is one of the most valuable skills you can pick up as a developer. It’s not as scary as it sounds, and once you’ve done it once, you’ll wonder why you waited so long.

This guide walks through the entire process: picking a VPS, provisioning the server, transferring your files and database, configuring your web server, and doing a clean DNS cutover with minimal downtime.

Why Move from Shared Hosting to a VPS?

Shared hosting is fine for hobby projects. But the moment you need custom PHP versions, background workers, Redis, or just consistent performance, shared hosting fights you at every step. A VPS gives you a dedicated slice of a machine — your own CPU, RAM, and storage — with root access to configure everything exactly how you want.

The main trade-off is that you’re responsible for the server. No cPanel magic. You’ll be managing packages, security updates, and your web server config yourself. That said, it’s genuinely manageable even if you’re not a full sysadmin.

Step 1: Choose Your VPS Provider

Two providers I’d recommend without hesitation are Hostinger and DigitalOcean. Hostinger offers very affordable VPS plans with solid performance and an easy UI for beginners. DigitalOcean is my go-to for more technical setups — their Droplets, documentation, and ecosystem of one-click apps are excellent for developers.

For most PHP/Laravel or WordPress migrations, a 2GB RAM / 1 vCPU droplet or equivalent is a reasonable starting point. You can always resize later.

Step 2: Back Up Everything on Shared Hosting

Before touching anything, grab a full backup. This means:

  • All website files (usually under /public_html)
  • Your MySQL/MariaDB database (export via phpMyAdmin or the command line)
  • Any cron jobs you’ve configured
  • Email accounts if you’re hosting mail (though I’d recommend moving mail to a dedicated service like Zoho or Google Workspace instead)

To export your database from shared hosting via SSH (if available):

mysqldump -u your_db_user -p your_database_name > backup.sql

Then download backup.sql to your local machine, or transfer it directly to the VPS later.

Step 3: Provision and Harden Your VPS

Spin up a fresh Ubuntu 22.04 (or 24.04) server. The first thing you do after logging in as root is create a non-root user with sudo privileges and set up SSH key authentication.

# Create a new user
adduser deploy
usermod -aG sudo deploy

# Switch to the new user and set up SSH keys
su - deploy
mkdir ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
# Paste your public key here
chmod 600 ~/.ssh/authorized_keys

Then lock down SSH by editing /etc/ssh/sshd_config:

PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes

Restart SSH: sudo systemctl restart sshd. Also enable ufw and open only the ports you need:

sudo ufw allow OpenSSH
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable

Step 4: Install Your Web Stack

For a typical PHP site or Laravel app, install Nginx, PHP, and MySQL (or MariaDB):

sudo apt update && sudo apt upgrade -y
sudo apt install nginx php8.3-fpm php8.3-mysql php8.3-cli php8.3-mbstring php8.3-xml php8.3-curl unzip -y
sudo apt install mysql-server -y
sudo mysql_secure_installation

Create a new MySQL database and user for your site:

sudo mysql -u root -p

CREATE DATABASE myapp;
CREATE USER 'myapp_user'@'localhost' IDENTIFIED BY 'strong_password_here';
GRANT ALL PRIVILEGES ON myapp.* TO 'myapp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 5: Transfer Your Files

Use rsync or scp to move your site files from shared hosting to the VPS. If your shared host has SSH access:

rsync -avz -e ssh user@sharedhost.example.com:~/public_html/ /var/www/myapp/public/

If you can’t SSH into shared hosting, download the files locally first and push from your machine:

rsync -avz ./public_html/ deploy@your-vps-ip:/var/www/myapp/public/

Then import your database on the VPS:

mysql -u myapp_user -p myapp < backup.sql

Step 6: Configure Nginx

Create a server block for your site:

sudo nano /etc/nginx/sites-available/myapp
server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/myapp/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Step 7: Set Up SSL with Let's Encrypt

Install Certbot and get a free certificate:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Certbot will automatically update your Nginx config to redirect HTTP to HTTPS and set up auto-renewal.

Step 8: Test Before Switching DNS

This is the step most guides skip. Before you change your DNS, test the site on the VPS by editing your local /etc/hosts file to point your domain to the new server IP:

123.45.67.89  yourdomain.com www.yourdomain.com

Open yourdomain.com in your browser. If everything looks right — styles loading, forms working, database queries returning results — you're ready to cut over.

Step 9: Update DNS and Cut Over

Lower your DNS TTL to 300 seconds (5 minutes) about 24 hours before the migration. This makes DNS propagation much faster when you're ready to switch.

When you're ready, update the A record in your DNS provider to point to the new VPS IP. With a low TTL, most visitors will start hitting the new server within minutes. Keep the shared hosting account active for 48 hours so any stragglers still cached on the old DNS get served.

Remove the /etc/hosts entry you added and verify the live site resolves to your new server:

dig yourdomain.com +short

Common Gotchas

  • File permissions: Make sure your web root is owned by www-data on Nginx setups. Run sudo chown -R www-data:www-data /var/www/myapp.
  • PHP version mismatches: Shared hosts often run older PHP. Test your app on the VPS with the new PHP version before cutting over.
  • Cron jobs: Re-add any scheduled tasks with crontab -e on the VPS.
  • Environment files: If you're running Laravel or any app with a .env file, make sure it's updated with new database credentials and APP_ENV=production.

Wrapping Up

That's the full picture of how to migrate from shared hosting to VPS. The process takes a few hours the first time, but it becomes second nature quickly. The payoff — full control, better performance, and a foundation to actually scale — is well worth the initial setup effort.

If you're evaluating VPS options, both DigitalOcean and Hostinger have solid entry-level plans that make this migration easy to do without breaking the bank. Start small, monitor your resource usage for a week, and resize if needed.