X
    Categories: Drupal 8 Tutorials, Tips and GuidesDrupal Tutorials, Tips and Guides

How to Update Drupal 8 Core

I’ve already explained the procedure of upgrading from Drupal 7 to Drupal 8 in a previous article.

Kudos to you if you’ve already ventured into the awesome realms of Drupal 8. Now as far as being on the cutting-edge goes, the next thing you will need on this adventure is to know how to update Drupal 8 to each of its latest versions.

Please note that in the world of Drupal, “Upgrade” means changing to a major version such as from Drupal 7 to Drupal 8. On the other hand, “Update” means updating to a minor version such as from Drupal 8.2.5 to Drupal 8.2.6.

In this tutorial I am going show you the steps needed to upgrade your Drupal 8 version to its latest releases.There are three main ways to update Drupal 8 Core, which are:

Since the composer and Drush methods are the easiest ones, I’ll show you how to update using these first. If in case, you aren’t able to update using these methods, you can go with the manual method which is a bit more complex but more thorough. It is a good practice to activate maintenance mode from your Drupal admin area before making any changes to your site.

Note:  Make sure to always backup your site before attempting to update to avoid any loss of data in case of any mishap.

Via Composer

Composer is a very powerful dependencies management tool for PHP based applications. To read more about Composer, you can head over to its official page for Drupal.

To update via composer simply run the “composer update” command in your site’s CLI (Command Line Interface).

Note: Composer is pre-installed on Cloudways servers.

Via Drush

Drush is a shell interface for Drupal that allows you to perform administrative tasks from your cloud server command line itself. If you prefer using Drush over composer to update your Drupal 8 core, you can follow the step given below to achieve that.

  1. Install Drush: To learn how to install Drush you can head over here.
  2. Backup: Always backup your site before making any core changes. You can make a backup of your site via drush through this command: drush archive-dump
  3. Put site in maintenance mode: As i mentioned before, it is always recommended to put your site in maintenance mode prior to making changes in your site. You can do this through Drush through the following command: drush sset system.maintenance_mode 1
  4. Run Update command in Drush: Now you need to run the following command to perform the update: drush pm-update
  5. Put site online: After update is performed, enter the following command to put your site back online: drush sset system.maintenance_mode 0

That’s it. It’s as simple as entering 3 commands to update your Drupal 8 core to drush.

Manually Updating Drupal 8 Core

This is the most tedious method but also the one which is most thorough. The steps involved in this method are as follows:

  1. Download and extract the latest version of Drupal from here.
  2. Login to your site’s admin panel using your admin credentials.
  3. Backup your database (ex: through PHPMyAdmin) and website before proceeding.
  4. Put your site in maintenance mode by navigation to configuration -> maintenance mode
  5. Remove ‘core’ and ‘vendor’ directory from your project. Also remove all the files from your project’s top-level directory, leaving out any files that you made changes to.
  6. Upload the core directory from the Drupal version you downloaded in step 1 to your project.
  7. Upload .htaccess, composer.lock and composer.json files from the downloaded Drupal version to your project.
  8. Upload vendor directory from the download Drupal version to your project.
  9. Go to yoursite.com/update where “yoursite” is your website’s domain name.
  10. Follow the onscreen instructions.

Conclusion

Updating your Drupal 8 core is a pretty straightforward and easy task once you grasp the basics of it. It is very important to keep your site updated for a variety of reason which I will cover in a future article, so be sure to stay tuned for that. We also saw in this article how tools like Composer and Drush make it incredibly easy to update your Drupal 8 core. Let me know in the comments if you get stuck at any point and I’ll be happy to help you out.

Hamza Zia: Hamza is a Drupal Community Manager at Cloudways - A Managed Drupal Hosting Platform. He loves to write about Drupal and related topics. During his free time, he can be seen obsessing over Football, Cars, Android and Gaming.