How to upgrade to a new version of Drupal 5
Upgrading to a new version of Drupal puts the fear of god into a lot of people. However, it does not need to be scary or time consuming. Because Drupal is highly modular, upgrading is a fairly painless exercise. Furthermore, it is necessary to maintain the latest version of your Drupal branch to ensure that you have the latest security patches.
In this tutorial, I will walk you through the process of upgrading from Drupal 5.6 to 5.7 (currently the latest version in the Drupal 5.x branch). You can follow this process for upgrading from an earlier version of Drupal 5.x. This is not to be used to upgrading to Drupal 6.x though and a tutorial for that will be posted at a later date.
I like to have a backup of the old version on the server and this tutorial assumes that you want the same. It is very handy to have the old version should you need it.
Step One: Create a 2nd version of your site
- FTP your live site files to your local computer
- Create a folder on your server called "version56" or similar. You can create a sub domain if you prefer.
- FTP your Drupal files to the "version56" folder
- You now have two version of your site that are exactly the same, and connected to the same database
Step Two: Create a new database
- Create a new database called example57. This is easy to do in CPanel by going to MySQL Databases
- Add the current user for your Drupal site to the new database
- Grant All Privileges for that user
- Leave it as an empty database for now
Step Three: Get the latest Drupal version
- Go to Drupal.org and download the latest version of Drupal (in the 5 branch). Currently that is 5.7
- FTP the latest version to your server, overriding your live files, with the exception of:
- modules folder
- themes folder
- sites folder
If your contributed modules are in the modules folder:
- Open the local copy of the module folder
- Open the live module folder
- FTP the files/folders from your local machine to the server
- This will ensure that you have the latest version of core Drupal modules, leaving your contributed modules unchanged
If your contributed modules are in the sites folder:
- You can go ahead and upload the modules folder with the rest of the new Drupal version, because the modules folder will only contain core modules
Note: do not touch the back up you made in Step One.
Step 4: Copy the database
- In phpMyAdmin, navigate to the current database (not the one created in Step One)
- Click on "Operations"
- In the "Copy To" field, enter the name of the new database (E.g. example57). You may need to prefix it with the sites user name
- Untick "CREATE DATABASE before copying", because we have already created it
- Ensure that "Structure and data" is selected. Hit go.
- You now have an exact copy of the database.
Step 5: Connect to the new database
- Open the settings.php file (sites/default/settings.php)
- On line 93 you will see the variable $db_url. The last part of the string is the database name. Change that to the new database name (E.g. example57)
- FTP the settings.php file back up to the server
- Your site now has the new Drupal files and is connected to the new database
- Login to the site and go to admin -> modules. Click on "update.php". On the update page, click on "run the database upgrade script" and then "update". This will update your core modules if required
You have now upgraded your site to Drupal5.7! And you have a backup copy of your old site running on the old version Drupal should you require it.
It is a good idea to check if your contributed modules need to be updated to a newer version. The Update status module is very handy for that.
If you have any questions, or require clarification, please add a comment below.