Tutorial Featured intermediate

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

Moving from shared hosting to a VPS doesn't have to be daunting. This comprehensive guide walks you through the entire migration process, from planning to execution, with minimal downtime.

Published:
Updated:
Reading time: 15 minutes
Data notes

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

Migrating from shared hosting to a VPS is a significant step that gives you more control, better performance, and scalability. But it can also feel overwhelming if you’ve never managed a server before.

This guide will walk you through the entire migration process, from planning to execution, ensuring minimal downtime and a smooth transition.

Why Migrate to a VPS?

Before diving in, let’s recap why you’re making this move:

Advantages of VPS over shared hosting:

  • Dedicated resources: No more competing with hundreds of other sites
  • Root access: Full control over your server environment
  • Better performance: Faster load times and more consistent performance
  • Scalability: Easy to upgrade resources as you grow
  • Custom configurations: Install any software you need
  • Better security: Isolated environment from other users

When to migrate:

  • Your site is slowing down due to resource limits
  • You need custom server configurations
  • You’re running multiple websites
  • You want to install specific software
  • You need better security and isolation

Pre-Migration Planning

Step 1: Assess Your Current Setup

Before you start, document everything:

Create an inventory:

## Current Hosting Inventory

### Domains
- example.com → Main domain
- blog.example.com → Subdomain
- anothersite.com → Add-on domain

### Databases
- example_main → WordPress database
- example_forum → Forum database

### Email Accounts
- info@example.com
- support@example.com

### SSL Certificates
- example.com (Let's Encrypt)
- blog.example.com

### Software Versions
- PHP: 7.4
- MySQL: 5.7
- WordPress: 5.8

Check your resource usage:

  • Log into your shared hosting control panel (cPanel, Plesk, etc.)
  • Check current resource consumption:
    • Disk space usage
    • Bandwidth usage
    • CPU usage limits
    • Memory limits
    • Number of databases

This helps you choose the right VPS plan.

Step 2: Choose Your VPS Plan

Based on your assessment, select a VPS plan:

Minimum requirements for typical WordPress site:

  • CPU: 1-2 vCPU
  • RAM: 2-4GB
  • Storage: 40-80GB SSD
  • Bandwidth: 2-4TB/month

For multiple sites or higher traffic:

  • CPU: 2-4 vCPU
  • RAM: 4-8GB
  • Storage: 80-160GB SSD
  • Bandwidth: 4-8TB/month

Use our tools:

Step 3: Choose Your VPS Provider

Consider these factors:

For beginners:

  • DigitalOcean - Best documentation and community
  • Linode - Good balance of performance and ease of use
  • UpCloud - Excellent performance with 100% SLA

For budget-conscious:

  • Hetzner - Incredible value in Europe
  • Contabo - Massive storage allocations
  • RackNerd (during promotions) - Ultra-low pricing

Important: Choose a provider with:

  • Good documentation
  • Active community
  • Reliable support
  • Data center near your target audience

Use our provider comparisons to decide:

Pre-Migration Checklist

Before you begin the actual migration:

1. Full Backup

Critical: Create a complete backup of your shared hosting account.

Backup checklist:

  • All website files (public_html, www, etc.)
  • All databases (MySQL, PostgreSQL, etc.)
  • Email accounts and messages
  • Configuration files (.htaccess, wp-config.php, etc.)
  • SSL certificates and private keys
  • Cron jobs
  • Any custom configurations

How to backup:

  • Use your hosting control panel’s backup feature
  • Use FTP/SFTP to download files
  • Export databases via phpMyAdmin or command line
  • Save all configurations locally

2. Choose Your Server Stack

Decide what software you’ll run on your VPS:

Popular options:

LAMP Stack (Linux, Apache, MySQL, PHP):

  • Most common choice
  • Good compatibility
  • Plenty of tutorials

LEMP Stack (Linux, Nginx, MySQL, PHP):

  • Better performance
  • More efficient
  • Steeper learning curve

Managed solutions:

  • Plesk - Easier for cPanel users (costs extra)
  • Cloudron - All-in-one platform
  • ServerPilot - Automated server management

3. Plan Your Migration Timeline

Recommended timeline (allow 1-2 weeks):

Week 1: Preparation

  • Days 1-2: Choose provider and plan
  • Days 3-4: Set up VPS and configure server
  • Days 5-6: Install required software
  • Days 7: Migrate files and databases

Week 2: Testing and Launch

  • Days 1-3: Test everything thoroughly
  • Days 4-5: Update DNS and monitor
  • Days 6-7: Monitor and optimize

Step-by-Step Migration Process

Step 1: Set Up Your VPS

1. Create and access your VPS:

# SSH into your new VPS
ssh root@your-vps-ip

# Update system
apt update && apt upgrade -y

2. Create a non-root user (security best practice):

# Create user
adduser username

# Give sudo privileges
usermod -aG sudo username

# Switch to new user
su - username

3. Configure firewall:

# Allow SSH
sudo ufw allow OpenSSH

# Allow HTTP/HTTPS
sudo ufw allow 80
sudo ufw allow 443

# Enable firewall
sudo ufw enable
sudo ufw status

Step 2: Install Web Server Software

Option A: LAMP Stack (Apache)

# Install Apache
sudo apt install apache2 -y

# Install MySQL
sudo apt install mysql-server -y
sudo mysql_secure_installation

# Install PHP
sudo apt install php libapache2-mod-php php-mysql -y

# Restart Apache
sudo systemctl restart apache2

Option B: LEMP Stack (Nginx)

# Install Nginx
sudo apt install nginx -y

# Install MySQL
sudo apt install mysql-server -y
sudo mysql_secure_installation

# Install PHP-FPM
sudo apt install php-fpm php-mysql -y

# Configure Nginx to use PHP
sudo nano /etc/nginx/sites-available/default
# Add PHP configuration as needed

Step 3: Migrate Your Files

Option A: Using SFTP/SCP

# From your local machine (with files downloaded from shared host)
scp -r /path/to/local/files username@your-vps-ip:/var/www/html/

# Or use SFTP client (FileZilla, WinSCP)

Option B: Using rsync (direct from shared hosting)

# From shared hosting (if SSH access available)
rsync -avz /home/username/public_html/ username@your-vps-ip:/var/www/html/

Option C: Using FTP client

  1. Download files from shared hosting using FileZilla/WinSCP
  2. Upload files to VPS using the same client

Set correct permissions:

sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html

Step 4: Migrate Your Databases

1. Export from shared hosting:

# Using mysqldump (if you have SSH access)
mysqldump -u username -p database_name > backup.sql

# Or use phpMyAdmin:
# - Select database
# - Click "Export"
# - Choose "Quick" method
# - Click "Go"

2. Import to VPS:

# Transfer file to VPS
scp backup.sql username@your-vps-ip:/home/username/

# On VPS, create database
mysql -u root -p
CREATE DATABASE database_name;
CREATE USER 'database_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database_name.* TO 'database_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

# Import database
mysql -u database_user -p database_name < backup.sql

3. Update application configuration:

For WordPress, update wp-config.php:

define('DB_NAME', 'database_name');
define('DB_USER', 'database_user');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');

Step 5: Configure Email (Optional)

You have two options:

Option A: Keep email on shared hosting

  • Point MX records to shared hosting
  • Only migrate website to VPS
  • Easier setup, recommended for beginners

Option B: Host email on VPS

# Install Postfix
sudo apt install postfix -y

# Install Dovecot (IMAP/POP3)
sudo apt install dovecot-core dovecot-imapd dovecot-pop3d -y

# Configure (beyond scope of this guide)

Alternative: Use email services like:

  • Google Workspace
  • Microsoft 365
  • Zoho Mail
  • ProtonMail

Step 6: Install SSL Certificate

Using Let’s Encrypt (Certbot):

# Install Certbot
sudo apt install certbot python3-certbot-nginx -y
# For Apache:
# sudo apt install certbot python3-certbot-apache -y

# Obtain certificate
sudo certbot --nginx -d example.com -d www.example.com

# Auto-renewal is configured automatically

Test SSL:

Step 7: Test Your Site

Before updating DNS:

1. Test using hosts file:

Windows:

C:\Windows\System32\drivers\etc\hosts
Add: your-vps-ip example.com

Mac/Linux:

sudo nano /etc/hosts
Add: your-vps-ip example.com

2. Test thoroughly:

  • Homepage loads correctly
  • All pages and posts work
  • Images and media load
  • Forms work (contact, login)
  • Database queries work
  • SSL works (https://)
  • Performance is good

3. Check error logs:

sudo tail -f /var/log/apache2/error.log
# Or for Nginx:
sudo tail -f /var/log/nginx/error.log

Step 8: Update DNS

When everything is working:

1. Update A record:

Type: A
Name: @
Value: your-vps-ip
TTL: 3600 (or lower during migration)

2. Update www subdomain:

Type: CNAME
Name: www
Value: example.com
TTL: 3600

3. DNS propagation:

Step 9: Monitor and Optimize

First week monitoring:

1. Check site speed:

  • Google PageSpeed Insights
  • GTmetrix
  • WebPageTest

2. Monitor server resources:

# Check CPU usage
top
htop

# Check memory
free -h

# Check disk usage
df -h

# Check processes
ps aux

3. Review logs regularly:

# Access logs
sudo tail -f /var/log/apache2/access.log

# Error logs
sudo tail -f /var/log/apache2/error.log

4. Optimize as needed:

  • Enable caching (Redis, Memcached)
  • Optimize database
  • Enable CDN (Cloudflare)
  • Configure backups

Post-Migration Tasks

1. Configure Automated Backups

Never skip this!

Simple backup script:

#!/bin/bash
# Backup script
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/home/username/backups"

# Backup files
tar -czf $BACKUP_DIR/files_$DATE.tar.gz /var/www/html

# Backup databases
mysqldump --all-databases > $BACKUP_DIR/database_$DATE.sql

# Delete backups older than 7 days
find $BACKUP_DIR -type f -mtime +7 -delete

Or use backup tools:

  • Restic - Encrypted backups
  • Borg - Deduplication
  • Automated backup services

2. Set Up Monitoring

Free monitoring options:

  • UptimeRobot - Basic uptime monitoring
  • StatusCake - Performance monitoring
  • Pingdom - Comprehensive monitoring
  • New Relic - Application performance

3. Security Hardening

Essential security steps:

# Disable root SSH login
sudo nano /etc/ssh/sshd_config
# Change: PermitRootLogin no

# Install fail2ban
sudo apt install fail2ban -y

# Keep system updated
sudo apt update && sudo apt upgrade -y

4. Optimize Performance

WordPress optimization:

  • Install caching plugin (W3 Total Cache, WP Rocket)
  • Optimize images (Smush, EWWW)
  • Use CDN (Cloudflare)
  • Enable Gzip compression
  • Minify CSS/JS

Server optimization:

# Enable Apache caching (if using Apache)
sudo a2enmod expires
sudo a2enmod headers
sudo systemctl restart apache2

# Enable PHP OPcache
sudo nano /etc/php/7.4/apache2/php.ini
# Add: opcache.enable=1

Troubleshooting Common Issues

Issue 1: Site loads but styling is broken

Cause: Incorrect file paths or permissions

Solution:

# Check permissions
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html

# Check .htaccess is present
ls -la /var/www/html/.htaccess

Issue 2: Database connection error

Cause: Wrong database credentials in config

Solution:

  • Verify database name, username, password
  • Check MySQL is running: sudo systemctl status mysql
  • Test connection: mysql -u username -p -h localhost

Issue 3: 500 Internal Server Error

Cause: .htaccess issues or PHP errors

Solution:

# Check error logs
sudo tail -50 /var/log/apache2/error.log

# Temporarily rename .htaccess
mv /var/www/html/.htaccess /var/www/html/.htaccess.bak

Issue 4: Slow performance after migration

Cause: Insufficient resources or poor configuration

Solution:

  • Upgrade VPS plan if needed
  • Enable caching
  • Optimize database
  • Check resource usage with top

Timeline Summary

Total estimated time: 1-2 weeks

Week 1:

  • Day 1: Choose provider and plan
  • Day 2-3: Set up VPS and install software
  • Day 4-5: Migrate files and databases
  • Day 6-7: Configure and test

Week 2:

  • Day 1-3: Thorough testing
  • Day 4: Update DNS
  • Day 5-7: Monitor and optimize

Common Mistakes to Avoid

1. Not Backing Up First

Mistake: Skipping backup before migration Solution: Always create full backup before starting

2. Rushing DNS Update

Mistake: Updating DNS before testing Solution: Test thoroughly using hosts file first

3. Forgetting Email

Mistake: Breaking email during migration Solution: Plan email migration separately or keep on shared host

4. Ignoring Security

Mistake: Leaving default configurations Solution: Configure firewall, disable root login, install fail2ban

5. No Monitoring

Mistake: Not monitoring after migration Solution: Set up monitoring and alerts immediately

Next Steps After Migration

1. Learn Basic Server Management

Essential skills:

  • SSH and command line basics
  • File permissions
  • Service management (systemctl)
  • Log reading
  • Basic troubleshooting

Resources:

2. Set Up Regular Maintenance

Monthly tasks:

  • Check for system updates
  • Review backup status
  • Monitor disk usage
  • Review error logs
  • Check SSL certificate expiry

3. Plan for Scaling

Monitor these metrics:

  • CPU usage (consistently >70%? Upgrade)
  • Memory usage (consistently >80%? Upgrade)
  • Disk space (less than 20% free? Upgrade)
  • Response time (getting slower? Consider CDN/caching)

Conclusion

Migrating from shared hosting to a VPS is a significant step that gives you more control, better performance, and room to grow. By following this guide and taking it step by step, you can ensure a smooth migration with minimal downtime.

Key takeaways:

  1. Plan thoroughly - Document everything before starting
  2. Backup completely - Never skip this step
  3. Test extensively - Use hosts file to test before DNS update
  4. Monitor closely - Keep an eye on everything for first week
  5. Learn continuously - Server management is an ongoing process

Need help choosing a VPS? Use our VPS Finder to compare plans based on your requirements and budget.

Already migrated? Check our guide on How to benchmark a VPS to ensure you’re getting optimal performance.


Last updated: January 2026 Found this guide helpful? Share it with others making the migration!

Next steps

Jump into tools and related pages while the context is fresh.

Ready to choose your VPS?

Use our VPS Finder to filter, compare, and find the perfect plan for your needs.