Move Your Drupal Business Website Without Drama – 3/4

In Part 2, we prepared for a Drupal website move by copying all the files and folders that power your website to your local hard drive. We then made a back up copy of these files and folders, as well as a back up copy of your database file. In Part 3 we will move these files to a new web host and test them without affecting your live site.

Step 6. Move your Drupal Code Base to Your New Web Host

Browse to the location of your website files on your hard drive. In Part 2, we used C:\websites\ as an example. Copy and paste \mysite.com.host-abc\, creating a third copy of your website code base. Rename this code base \mysite.com.host-xyz\, where “host-xyz” refers to your future home for the website. If you have followed this article from the beginning, you now have 3 versions of your website on your hard drive: the current live site code base, a back up of the live site code base, and now a new copy of the code base appended with “host-xyz”.

Copy Drupal Codebase

Why all the copies of the code base? We’re being conservative. It’s wise to structure your local copies of the website in a way that ensures you always have a clean backup, as well as a clear understanding of which code base is associated with which hosting account.

On your hard drive, in \mysite.com.host-xyz\, double click sites > default. You should see a \files directory and files named settings.php and default.settings.php. Settings.php contains the connection information for your current live site’s database. Delete settings.php. Now, make a copy of default.settings.php and rename it settings.php. The goal is to have an unconfigured version of settings.php for the Drupal installer to work with. If it encounters a version of settings.php with database connection details from your other website host, it won’t let you install Drupal.

New Settings php

Using your FTP client, push the entire \mysite.com.host-xyz\ directory to the root of your new web hosting account. Refer to your welcome email from your new hosting provider for your FTP credentials, or contact them directly. While this large FTP job is running, set up a new database for your Drupal website. The method for creating a database differs among hosting companies. You will either accomplish it via an administrative console on the hosting provider’s website, or you might need to contact support. Your goal is to have a new blank MySQL database created, and obtain the following information:

  • Database name
  • Database user name
  • Database password
  • Database host: This is often “localhost”, which means your database is on the same server, but not always. Check with your hosting provider.

Step 7. Configure Your Hosts File

Your hosts file is a simple text file used by your operating system to map hostnames to IP addresses. In this step, we’ll add a custom entry to your computer’s hosts file. This entry overrides DNS and allows you to point your domain at the ip address of your new web host before DNS is updated on the web. This is a great way to test your website in its future home without affecting the current website for the rest of the users on the internet. Follow this tutorial to get familiar with your hosts file:http://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/.

Open Notepad with administrative privileges and use it to open your hosts file. For Windows 7 users, hosts is located at c:\windows\system32\drivers\etc\hosts. It’s a little tricky because hosts doesn’t have a file extension, like .txt or .doc. If you get stuck, refer to the above tutorial.

Add to hosts file

Add the following line to your hosts file. Replace the ip address with the ip address provided by your new hosting provider.

  • 74.125.225.176 mydomain.com www.mydomain.com

Don’t forget to save this change to your hosts file.

Step 8. Run the Drupal Installation Script

Close all browsers and open a new one. This step is to ensure your hosts file change takes effect. Visit your domain. You should not see your live website. Instead, you should see the Drupal installation screen. This is a good sign. It means you’re seeing your new hosting provider’s web server. Run the Drupal installation script. Refer to http://drupal.org/documentation/install/run-script if you run into any issues that require troubleshooting.

When complete, you will have a fresh Drupal website installed on your new hosting account, but you will be missing all of your content and site design. Don’t worry – it’s there. You just need to restore your database.

Step 9. Restore Your Drupal Database

Because you used the Backup and Migrate module to create your database backup, you must use it to restore your database. Therefore, your first step is to enable Backup and Migrate on your new Drupal site.

  • Drupal 6 users: Log in to your Drupal site. Click on Administer > Site Building > Modules and look for “Backup and Migrate”. Ensure Backup and Migrate is enabled.
  • Drupal 7 users: Log in to your Drupal site. Click on Modules and look for “Backup and Migrate”. Ensure it is enabled.

Follow the instructions included with the module and restore the database backup you created and saved to your hard drive in Part 1. If you run into any error messages, visit the Backup and Migrate module’s home page: http://drupal.org/project/backup_migrate for hints.

Step 10. Configure Your Drupal File System Settings

The goal of this step is to make sure the file system paths you had configured on your old webserver are still valid on the new webserver. Sometimes these can change, depending on your situation. They must be configured for your website to work properly.

  • Drupal 6 users: Log in to your Drupal site. Click on Administer > Site Configuration > File System
    Your file system path should be something like sites/default/files. Your temporary directory should be something like sites/default/files/tmp.
  • Drupal 7 users: Log in to your Drupal site. Click on Configuration > File System (under Media)
    Your public file system path should be something like sites/default/files. Unless you need to use a private file system, you don’t need to provide a private file system path. Your temporary directory should be something like sites/default/files/tmp

A good test is to click save and see if Drupal is happy with your selected paths. If there is a permissions issue, you will receive a helpful warning message that can help you troubleshoot. Permissions issues might require accessing your new hosting provider’s admin console, or a call to support. For more information on the Drupal file system, visit http://drupal.org/node/394704.

Step 11. Clear Your Cache

Your site might very well look odd at this stage. That’s because you need to clear your Drupal cache.

  • Drupal 7 users: Log in to your site. Click Configuration > System > Performance (under Development). Click clear all caches.
  • Drupal 6 users: Log in to your site. Click Administer > Site Configuration > Performance and scroll to the bottom of the page. Click Clear cached data.

At this point, you have moved your files up to your new hosting account, created a hosts file entry to allow you to test your new site without impacting your live site, installed Drupal, restored your database, and configured your file system. Finally, you cleared your cache, allowing you to see your website as it runs on a new hosting account at your new hosting provider. Now is a great time to test and make sure all of your pages look the way they should. Pay special attention to pages with attached or uploaded files, such as PDFs and pictures. Test your webforms and make sure your new hosting account sends mail from the website properly.

In Part 4, we’ll finalize the move by updating DNS and telling the world your website now lives at a new server.

Learn about good design

More Articles