A passion for web development

Share

Category
Articles

Migrating drupal to a new server

 

There are some times when you want to change servers, domain names or simply having a simple backup to your website. Drupal backup and migrate also can be achieved through the module called Backup And Migrate. In this tutorial I won't be talking about drupal modules related to the backing up and migration of your data, however I will be talking about achieving this task manually through using simple tools that can be found in a common hosting companies or virtual/dedicated servers.

To cut the story short the following is a list of requirements you need before migrating drupal:

1- Make sure the file sittings.php located in /sites/default/ has a read and write permission if you are intended to move your directory around the new server. The settings.php file will still be downloaded from a compressed or zipped file If the file doesn't have a read and write permission, however if you want to move the unzipped directory around the new server then the result will be that everything will be copied apart of that file.

Currently the default directory has the permission of 0444 which best to set it to 0755 - 777 but make sure to put it back after you finish from it. Also make sure the setting.php files has a permission of at least 644.  If the new copied directory is not zipped then you must change the permission of the directory/file before copying and pasting to the new location .

 

2- Copy the directory of your drupal installation. The directory is the start of your virtual path ( / ). This directory should be all copied using:


a- Simple copy or


b- Compress the folder. Most web management tools allow you to do that using the virtual host interface example web-min has it and also cpanel. In cpanel it is located at the end of the buttons manu in file manger. Hint in the same line where edit, rename, delete etc.

 

c- Download the compressed or copied folder to your local computer

 

3- Create a database backup.  It can be achieved in so many ways but I will explain about using phpmyadmin which it is a web based mysql UI for the databases. Note it is not a tool for complete mysql management.


a- Go to old database and  and export the database in .sql extension.


b- Save the resulted file in your local computer

 

4- Upload the directory of the website to your new server. This directory could be a full copy of the directory or compressed file you have copied and or compressed in step 2.

 

5- Create a new database and make sure that you remember its name or you could simply use the old database name. With cpanel your database might have a prefix but this shouldn't be a problem. In this stage you have the chance to change your database name with minimal cost.

You can create a database in so many possible ways but the easiest is using the mysql database tools that can be found in most web based server administration tools such as webmin and cpanel. In cpanel you can use "Database Wizard or MySQL Databases ". These two tools are located next to each other where you can select phpmyadmin from the home page of the cpanel under databases.

 

6- Go to your newly created database using phpmyadmin but make sure you don't get confused between your old database and new database especially if you are using the same tools to work with both accounts. Example using phpmyadmin in both databases as well as the same name can easily confuse any one.


a- Go to import and import your file created in step 3. The tables will be installed directly.

 

7- Go to your sever where you want to upload the new drupal migration and unzip the file or paste the directory there. If the directory was a compressed file then everything would be unpacked with no problem. If the directory is a copy and paste then make sure you have enabled the correct permission mentioned in step 1.

 

8- Navigate to /sites/default and edit settings.php as follows:

 

$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'name of the database you have created in step 5',
'username' => 'Your user name in the new server',
'password' => 'Password',
'host' => 'localhost', /* in most cases it will be localhost but make sure to get the domain name or IP address for your mysql server */
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);

 

9- Set up the dns:


a- Go to your domain server in your new account that holds your migrated drupal installation. You can achieve this in lots of ways such as editing the zone file or the easy way is using the cpanel. The cpanel will actually combine two steps in one. Creating a dns setups as well as adding a virtual host.


b- Configure appache to host your new domain by creating a virtual host.


c - Or use the domain addon in cpanel to point your domain to a directory that hold your new drupal migration which as mentioned previously will create both dns pointing and virtual or simple addon to a virtual host.

 

10- The final step is to tell your register to point the domain to the newly assigned domain name servers.

The confusing part might be in the dns and apche configuration. Lots of skills are needed in order to configure apache and the dns servers which are beyond the scope of this article. Using the addon domain in cpanel actually ease the dns and apche virtual host creation. Here don't confuse the dns pointing from your domain name registered to your own domain name servers. Your domain name servers should be up and running in order for this task to be completed.

You won't be able to create a virtual host without the correct  server configuration. New domain registrars can offer free service to create A records and general management of your domain. This is enough for most small businesses who have a few domains. Dealing with your own domain name server if you are going to have lots of domains. Again cpanel makes all the configuration required in a few clicks, but remember to point your domain to the correct name server. 

 

11- Sit and wait for about 2 hours for the new settings to take effect and then check your domain again.

 

I advice you to use a trial run first on a domain that you are not using for business and on drupal site that doesn't have visitors. The hardiest part of learning the domain name servers is watching the change that doesn't take effect immediately. There is work around this problem such as using nslookup youdomainname your dns to check if the domain is configured correctly in your new server.

Dns configuration might be another subject I will be talking about in the future. Let me know if you need help in configuring your dns server for you. 

Contact
01902 637 708