LC
Back to Tutorials
devopsintermediateMarch 15, 2025

How to Migrate a Drupal 9 Website from CloudPanel to cPanel

Step-by-step guide to migrating a Drupal 9 site between hosting stacks — from CloudPanel + LiteSpeed to cPanel + Apache.

drupalmigrationcpanelcloudpanelserver

Migrating a Drupal 9 site to a new server — especially when switching hosting stacks (like from CloudPanel + LiteSpeed to cPanel + Apache) — can be complex. This tutorial walks you through the full migration process, including file/database transfer, production setup, and resolving common Drupal issues.

Step 1: Backup Files from CloudPanel Server

From the source CloudPanel server, create a .tar.gz backup of your Drupal site files:

bash
      tar -czf /mnt/backup/website_backup.tar.gz /home/user/htdocs/project-folder

    

Step 2: Transfer Files to the New Server

Download the archive on the new cPanel server:

bash
      wget http://your-old-server-ip/backup-link/website_backup.tar.gz

    

Or use scp for secure copy:

bash
      scp user@old-server:/path/to/website_backup.tar.gz .

    

Step 3: Import the SQL Database

Uncompress the SQL backup

bash
      gunzip backup.sql.gz

    

Clean the dump if needed

If the SQL file contains a CREATE DATABASE statement and you don't have permission, strip it:

bash
      grep -v "CREATE DATABASE" original.sql > clean.sql

    

Import into MySQL

bash
      mysql -u your_user -p your_database < backup.sql

    

Step 4: Set the Correct Document Root

On cPanel, if you can't change the document root directly, use a symlink:

bash
      cd /home/your_cpanel_user
rm -rf public_html
ln -s /home/your_cpanel_user/drupal/web public_html

    

This way public_html resolves to the correct Drupal public folder.

Step 5: Configure for Production

Edit sites/default/services.yml to disable Twig debugging and enable caching:

yaml
      parameters:
  session.storage.options:
    cookie_secure: true
    cookie_lifetime: 86400
    gc_maxlifetime: 86400

  twig.config:
    debug: false
    auto_reload: false
    cache: true

    

Update settings.php for performance:

php
      $settings['cache']['default'] = 'cache.default';
$config['system.performance']['css']['preprocess'] = true;
$config['system.performance']['js']['preprocess'] = true;

    

Step 6: Run Cron Jobs

Using Drush:

bash
      drush core:cron

    

Or set up a system cron job:

bash
      */30 * * * * /usr/bin/drush --root=/home/your_user/web cron

    

Step 7: Enable HTTPS

Use Let's Encrypt via cPanel or upload your SSL certificate. Verify HTTPS is working using SSL Labs Test and the browser padlock check.

Step 8: Clean Up Legacy Modules

If your old server used LiteSpeed Cache and the new one uses Apache:

bash
      # Clear cache
drush cr

# Find references to LSCache
grep -r 'lscache' /tmp/config-export/

# Remove the module folder
rm -rf web/modules/contrib/lscache

    

Common Errors

RouteNotFoundException: lite_speed_cache.form

Cause: LSCache module removed, but route still referenced.

bash
      drush cr

    

Final Steps

  • Regenerate image styles: drush image:flush
  • Check for broken links (Screaming Frog)
  • Export/import Drupal config if using Configuration Management
  • Set up Google Search Console, update robots.txt and sitemap