Manual Migration of WordPress from cPanel to a Fresh Ubuntu 24.04 VPS without Plugins

Introduction

At ByteHosting, we understand that migrating your WordPress site from a cPanel environment to a fresh Ubuntu 24.04 VPS can seem daunting, especially without relying on plugins. That’s why we’ve put together this comprehensive, step-by-step guide to help you perform a manual migration efficiently and securely. Whether you're looking to improve performance, gain more control, or simply want a clean setup, this tutorial will walk you through the entire process.

Prerequisites: Backup of WordPress Site and Database

Before starting the migration, it’s crucial to create backups of your WordPress files and database. This ensures you can restore your site if anything goes wrong during the transfer.

  • Backup WordPress Files: Use cPanel’s File Manager or an FTP client to download all files in your WordPress directory.
  • Backup Database: Export your MySQL database via cPanel’s phpMyAdmin. Select your database, click on the Export tab, choose the Quick export method, and save the SQL file.

Setting Up a Fresh Ubuntu 24.04 VPS

Our first step is to prepare your new server. We recommend deploying a clean Ubuntu 24.04 VPS, which you can easily do through ByteHosting’s cost-effective plans. Once your server is ready, connect via SSH:

ssh username@your-server-ip

Update your package list and upgrade existing packages:

sudo apt update && sudo apt upgrade -y

Installing Necessary Software

To run WordPress, you need a web server, PHP, and MySQL. Install the LAMP stack:

sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql php-cli php-curl php-gd php-mbstring php-xml php-zip -y

Secure your MySQL installation:

sudo mysql_secure_installation

Transferring WordPress Files via SCP or rsync

Next, transfer your WordPress files from your cPanel backup to your new server. We recommend using rsync for its efficiency and reliability:

rsync -avz /path/to/your/backup/wordpress/ username@your-server-ip:/var/www/html/yourdomain

Ensure the destination directory has proper permissions:

sudo chown -R www-data:www-data /var/www/html/yourdomain

Exporting and Importing the MySQL Database

Now, import your database backup into MySQL:

  1. Create a new database and user:
sudo mysql -u root -p
CREATE DATABASE wordpress_db;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

    Read more