How to Migrate Drupal Site

ray| 2016-01-02 Drupal, Web Hosting Comments( 0 )

There are many reasons you want to transfer a Drupal site from one server to another, such as you just change your Drupal hosting, or you want to move Drupal from development environment to production. As a php application, moving Drupal to new server is a relatively simple task, but some preparations are still needed to make it a smooth process.

Check your new server configuration

The first thing you should do is to check the configurations of the new web hosting server and make sure it could give good support to your Drupal application. Highly recommend to checkout this Drupal Hosting Guide and Drupal System Requirement before the moving. And in below, we will list out some basic configuration you should check.

php and Database

Ideally, the version of php & database (such as MySQL) should be the same of your original server. If not, make sure they are compatible with the version of Drupal you have installed. You should also check memory_limit of your php application, set it to be the same of your previous environment. If you reduce the value, make sure you have tested your Drupal site before the moving. If you increase this value, any value over 64MB should be evaluated carefully. To change the value of memory_limit, please refer to How to Increase PHP Memory Limit. To know the version of php and database, as well as memory_limit setting, you could leverage phpinfo().

Apache

If you have enabled “Clean URL” for your Drupal site, you should make sure 'mod_rewrite' extension is installed in Apache.

Replace Absolute URL path to Relative URL path if any

If you migrate Drupal from Development environment to production or Change the domain name of your site, you should check have you use any absolute URL path in your code or your articles. If yes, you might need to refactor your code, or use MYSQL REPLACE function to replace those URL information in the database.

Others

If your Druapl site relies on some other features, such as memory cache etc, please make sure those are installed in your new server as well.

Start migration

Once finish the validation of the new server, you can start the migration.

Clean Drupal Cache

To increase the performance, Drupal cache many data (such as the whole page, or block, etc) in database. And those cache records are very large ,and might cause "Fatal Error: Allowed memory size of xxxxxx bytes exhausted" when importing them again using phpMyAdmin. To avoid this happen, the first step of migration is to Clean Drupal Cache in "Administration » Configuration » Development".

Move Database

Let’s use MySQL as an example as it’s the most used database in Drupal application. Here are the steps to process it:

  • In new server, create a new database and the relevant database user. Assign “All” permission of database to this user.
  • Export your old MySQL database database using phpMyAdmin, or mysqldump command if you have shell access.
  • Import the exported file to the new database by phpMyAdmin, or use mysql Command if you have shell access.

When importing data using phpMyAdmin, you might see the issue like “Fatal Error: Allowed memory size of xxxxxx bytes exhausted”. This is caused by large data record in your export file, and this large record normally come from Cache table used by Drupal. To resolve this issue, you can follow below methods:

  • MySQL command to import the file
  • Or manually remove those cached data in the backup file
  • Or increase the value of memory_limit for php

Move Drupal Source Code

Now, we can upload Drupal Code to home directory of the new server. After this, we need to change the settings.php file under the site and assign the new database, user name, and password value in the database connection section. Done, you should be able to see your new Drupal site up now. And before testing, don't forget to clean the cache of your browser cache.

Tagged with:

We hope webmasters to share and promote the good articles ,Please click herecontribute

You need to log in to commentLogin|Register

Be the first to comment!