[Theory] How to Migrate a Drupal 7 Website to a New Server with Cpanel

Submitted by Rajasekhar on Sat, 11/17/2018 - 19:14

Steps to migrate the website are:

  1. Create a backup of the website from the existing server

    1. Create a zip file of the source folder

      1. Note: You may have to check with the person/team that handles the older server.

    2. Take a database backup of the website using backup & migrate module of Drupal.

      1. Note: If you do not have permissions, you may ask a person/team that handles the old website.

  2. Log in to the new hosting server.

  3. Add the domain as an Addon domain . Give an appropriate name for the folder while adding addon domain. There will also be a subdomain created for the addon domain.

  4. Create a new database and a new user in Cpanel. Assign the user to the newly created database and grant all the privileges

  5. Go to phpMyAdmin in Cpanel and navigate to the newly created database and import the backup of the database of the website to the same

  6. Upload the source file zip to the folder in the new server.

  7. Unzip the file and navigate to sites folder.

    1. check whether write permission is enabled for the 'default' folder or not.

    2. If not, enable the same and enable the write permissions for the file 'settings.php'.

  8. Edit the file settings.php and change the database configuration to point to the new database.

    1. $databases = array (
        'default' => 
        array (
          'default' => 
          array (
            'database' => 'TempDatabase',
            'username' => 'TempUsername',
            'password' => 'TempPassword',
            'host' => 'localhost',
            'port' => '',
            'driver' => 'mysql',
            'prefix' => '',
          ),
        ),
      );

  9. Also ensure that .htaccess is present in the source folder. If not, upload the same from the downloaded drupal source folder from drupal.org.

  10. Hit the subdomain URL in the browser and check whether the site is loading properly or not.

  11. Also, log in to the website and make sure that even login is working. 

  12. Change the nameservers of the domain to point to the new server.

    1. Note: You may have to contact the person/team that handles Domain Name System for your company.