How To Upgrade Drupal

How To Upgrade Drupal

In this article, we will discuss how you can upgrade your Drupal application to a newer Major version.

As most popular CMS applications Drupal has built-in PHP scripts which could be executed through the Composer package manager in order to upgrade the version of Drupal.

In order to use Composer, you will have to connect to your hosting account using an SSH connection and to navigate to the root directory of your account.

IMPORTANT: Before proceeding with the upgrading process, we highly recommend creating a backup of the website's files as well as its database in case something goes wrong during the upgrading process.

In this tutorial, we will be upgrading from Drupal 8.9.1 to Drupal 9 which is the latest version of Drupal to date.

Before upgrading, please make sure that you have checked the requirements of the new Drupal version. For the requirements of the Drupal 9 version, you can find more information here:

Once you have generated a backup of your Drupal-based website and are ready to update the application, you may proceed by setting full permissions to the configuration files of your website by executing the following three commands in the SSH window:

chmod 777 sites/default

find sites/default -name "*settings.php" -exec chmod 777 {} ;

find sites/default -name "*services.yml" -exec chmod 777 {} ;

The next step is to download the packages of the new Drupal version which could be achieved by executing the following command:

composer require drupal/core-recommended:^9.0.0 drupal/core-composer-scaffold:^9.0.0 drupal/core-project-message:^9.0.0 –update-with-dependencies –no-update

Once you execute the command, an output message will be shown in the SSH Terminal stating that the Composer was just updated.

Since the new packages have been downloaded, you may now proceed by updating the Drupal's code by running the following command in the SSH Terminal:

composer update

Once executed, all of the Drupal's code will be updated to its latest stable version. Please note that this process can take a while depending on how large your website is.

Now that the code was upgraded, you will need to execute the following command in order to update the database of the Drupal application:

drush updatedb

Now that you have successfully upgraded the Drupal application, you will have to restore the normal permissions of the configuration files by running the following commands:

chmod 755 sites/default

find sites/default -name "*settings.php" -exec chmod 644 {} ;

find sites/default -name "*services.yml" -exec chmod 644 {} ;

And that concludes the final step. Congratulations, you have successfully upgraded your Drupal-based website.