Drupal 7 First Look
上QQ阅读APP看书,第一时间看更新

Upgrading from Drupal 6 to Drupal 7

The Drupal upgrade process allows you to update your site from Drupal 6 to Drupal 7 using a simple procedure. The upgrade process automatically corrects any functionality from Drupal 6 that was removed in Drupal 7 and updates content to use new features where possible.

Before beginning the upgrade process, it is imperative that you make a backup of your site and test the upgrade procedure on a test instance of your site before upgrading your production site. Contributed modules may require additional steps to upgrade them from Drupal 6 to Drupal 7. We covered some of these cases in the last chapter as we reviewed some of the new contributed modules that are available for Drupal 7. If we did not cover a module you are using in Drupal 6, refer to the project page for that module on Drupal.org to see if any additional steps need to be taken during the upgrade process.

You should also review any contributed modules you are using to make sure they have a Drupal 7 version available or that there is a suitable alternative which provides similar functionality if there isn't an upgrade.

To demonstrate the upgrade process, a simple Drupal 6 site has been created and the Devel module (http://drupal.org/project/devel) has been used to populate the site with sample data. The site includes a blog, forums, a bunch of comments, and regular pages and stories. The home page looks like the following screenshot:

Upgrading from Drupal 6 to Drupal 7

To upgrade your site, you will have to perform the following steps. These steps need to be done in one sitting so that your login information is not lost and the process is not interrupted:

  1. Back up your site's database. If you are using MySQL, you can use phpMyAdmin to export your database to a file. You can also use the Backup and Migrate module (http://drupal.org/project/backup_migrate) to make a backup of your database. The Backup and Migrate module has the added benefit of being smart enough to know which tables you don't need to back up (for example, cache tables), and it can back up any data source.
  2. Back up your entire Drupal 6 installation. Pay careful attention to make sure that you have all of the information in your sites directory since this is where configuration files, contributed modules, custom code, and custom themes are stored. You should also back up any files that may have been uploaded to the server as well as any other custom code you may have on the site. You may even want to make two backups—one of the entire site, and one of just your sites directory, additional files, and other customized code. Log in to your site as the first user. This user will be needed to run the upgrade process.
  3. Set your site to be offline. This prevents users from accessing the system and interfering with the upgrade process or from seeing the site when it is not fully operational. To put your site into offline mode, you will need to visit the site maintenance page of your Drupal 6 site. This can be reached at http://www.yoursite.com/admin/settings/site-maintenance or by clicking on Administer | Site configuration | Site maintenance from the menu:
    Upgrading from Drupal 6 to Drupal 7
  4. After your site is in maintenance mode, you will need to disable any custom modules and custom themes that you installed. This will ensure they do not interfere with the upgrade process. As part of this, you will need to disable your site theme and return to a core theme such as Garland or Bluemarine. If you have deactivated these themes, you will need to reactivate one or the other.
  5. Remove all of the old Drupal files from your site including any old Drupal 6 modules and themes. This will prevent the old files from conflicting with Drupal 7.
  6. Download and unpack Drupal 7 if you have not done so already and copy it to the root directory for your site.
  7. Copy the information from your old sites directory back to your site. Especially make sure to copy your settings.php file as well as any files that were uploaded to the site. You do not need to copy any Drupal 6 themes or modules back to your site.
  8. If you customized core files such as .htaccess or robots.txt, you should reapply the changes rather than copying the files over. This will preserve changes made from Drupal 6 to Drupal 7.
  9. Double check your settings.php file to make sure that it has all of the correct information for your site.
  10. Run update.php by visiting http://www.yoursite.com/update.php. This will start the upgrade process.
  11. Drupal will first display a message describing the upgrade process and reminding you to back up your database and source code, as shown in the following screenshot:
    Upgrading from Drupal 6 to Drupal 7
  12. After you click on the Continue button, Drupal will display a screen describing the updates that will be applied during the upgrade process.
    Upgrading from Drupal 6 to Drupal 7
  13. Selecting the Apply pending updates button will begin the upgrade process. During this procedure, you should not interrupt the installation process or refresh the page. The page will automatically update to show you the progress of the upgrade as each update is applied.

When the upgrade is complete, Drupal will display a log describing the changes that were made as well as any errors that may have occurred. After you complete the upgrade, you can continue to either the front page of your site or the administration section.