Migrating Your WordPress Site from Local to cPanel Subdomain: A Step-by-Step Guide

Sospeter Mong'are - Aug 31 '23 - - Dev Community

Introduction

Migrating a website is a crucial task that demands precision and attention to detail. Whether you're a web developer fine-tuning your creation or a website owner looking to take your platform live, moving a WordPress site from your local computer to a subdomain on cPanel requires a systematic approach. In this comprehensive guide, we'll walk you through each step to ensure a seamless transition.

Step 1: Creating a Subdomain in cPanel
Before you embark on the migration process, you need a designated space on your cPanel account for your website. Follow these steps to create a subdomain:

  1. Access cPanel: Log in to your cPanel account using your credentials.
  2. Locate Subdomains: Navigate to the "Domains" section and select "Subdomains."
  3. Craft Your Subdomain: Choose a name for your subdomain (e.g., "blog" for blog.yourdomain.com) and select the main domain to associate it with.
  4. Define Document Root: Set the document root to specify the folder where your WordPress files will reside. This is crucial for proper functionality.
  5. Create Subdomain: Click the "Create" button to finalize the creation of your subdomain.

Step 2: Compressing and Uploading WordPress Files

With your subdomain set up, it's time to prepare your WordPress files for migration:

  1. Package Local Files: Compress all your WordPress files into a single zip archive on your local computer. This ensures an organized transfer.
  2. FTP Connection: Use an FTP client like FileZilla to connect to your cPanel hosting account.
  3. Access Subdomain Directory: Locate the folder you designated for your subdomain. This is where you'll upload your WordPress files.

Step 3: Unzipping the WordPress Files

Once your files are securely uploaded, proceed with extracting them in the subdomain directory:

  1. Extract Files: Upload the compressed zip archive to the subdomain folder in cPanel. Then, extract the contents directly into the same folder.

Step 4: Creating a Server Database and User

The backbone of any WordPress site is its database. Here's how to set it up:

  1. Enter MySQL Databases: Within cPanel, navigate to the "Databases" section and select "MySQL Databases."
  2. Database Creation: Assign a name to your new database and confirm the creation.
  3. User Setup: Scroll down to "MySQL Users," define a username and a robust password, and generate the user.

Step 5: Exporting and Editing the Local Database

To ensure your site retains its functionality post-migration, your local database needs some attention:

  1. Access Local Database: In a tool like phpMyAdmin, select your local WordPress database.
  2. Export SQL File: Export the database as an SQL file for later use.
  3. Edit SQL File: Open the SQL file in a text editor and perform a comprehensive search-and-replace operation. Change all instances of "localhost" to your subdomain link (e.g., from http://localhost to http://subdomain.yourdomain.com).

Step 6: Importing the Edited Database to Server

With your edited database at the ready, it's time to import it on your cPanel server:

  1. Database Import: Access cPanel's "phpMyAdmin" and select the database you created earlier.
  2. Import SQL File: Navigate to the "Import" tab, upload the edited SQL file, and execute the import.

Step 7: Testing Your Website

Your migration journey isn't complete without thorough testing:

  1. Visit Subdomain: Open your web browser and head to your newly created subdomain URL (e.g., http://subdomain.yourdomain.com).
  2. Functional Check: Explore every nook and cranny of your website. Verify that all pages, images, links, and interactive elements are functioning correctly.
  3. Permalink Adjustment: Log in to your WordPress admin dashboard and update your permalink settings to ensure seamless navigation.

Conclusion

Congratulations! You've successfully migrated your WordPress site from your local computer to a subdomain on cPanel. Migrating a WordPress site from your local machine to a cPanel subdomain might seem complex, but by following this comprehensive guide, you've conquered the process step by step. You've transformed your local masterpiece into a live website accessible via a subdomain. With your commitment and attention to detail, you've minimized potential issues and ensured a smooth transition. Your website is now poised to thrive in its new online home.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .