Why should you depend on your managed IT service provider for every minor update that you need to make to your Drupal 8 core?
Especially if we're talking about updates that would require no more than a couple of minutes of your time, a few “precautions” to take beforehand and a couple of simple commands for you to enter?
Therefore, take this “tutorial” here as a “DIY” type of guide: one empowering you with knowledge on how to update your current Drupal 8 to its latest version. Or, better said: “take this tutorial here as 3 DIY separate guides”, or rather as a 3-in-1 guide, since we'll do our best to explain to you the three different methods available to you for updating your Drupal 8 core yourself.
And, before we proceed, just a quick specification only to make sure that we're on the same page: on “Drupal planet” upgrade refers to leveling up to a major version of the CMS (e.g. from Drupal 7 to Drupal 8), whereas update refers to leveling up to a minor or patch version of Drupal 8 (e.g. from Drupal 8. 2.6. to Drupal 8.2.7).
OK, so now that we've got this tiny detail straight, let's start with the list of “precautions” that we've just mentioned here before we jump straight to detailing the 3 methods for you to update your Drupal 8 core with:
Precautions to Take & Extra Info to Consider Before You Update
- take it as a best practice, as an important piece of advice or as a “warning”, but mind you never skip this critical preliminary step: make a full backup of your database and of all your files before you proceed with the update; also, remember to activate the maintenance mode from your admin panel, before you go ahead and apply changes to your Drupal 8 website. These 2 apparently negligible precautions can actually make the difference between an event-less updating procedure and one leading to critical data loss and leaving you with no backup solution to retrieve them!
- consider updating a test copy of your site first, prior to running the update on its live version. You never know what impact those seemingly minor updates that you'll be running can have on your site's behavior. Better safe than sorry!
- this as a useful tip: each new release of Drupal comes with its own release notes listing not just all the improvements/changes applied to that specific version of Drupal, but also guidelines on how to update or to upgrade it to future releases, as well. So, you may want to have a quick look at those notes, as well, before you jump straight to the updating process.
Update Your Drupal 8 Core Via Drush
Just a few words about Drush: it's Drupal's shell interface that enables you to perform your administrative tasks, quick and easy, right from your command line (how familiar are you with working in a command-line tool?)
And these are all the steps you need to take if you choose the Drush-way for updating your Drupal 8 core:
- First and foremost: you install Drush (obviously!).
- With the risk of being overly “annoying”, we need to stress, once again, that it's vital for you to backup your site before you make any changes (and especially since it's core changes that you'll be making in this case here). Use Drush for that: run the drush archive-drump command.
- Also, as already mentioned, you need to activate the maintenance mode prior to the update process itself. Why should you run any risk, especially when there's just one simple Drush command for you to enter: drush sset system.maintenance_mode 1?
- It's now that you actually run the update procedure itself, through another Drush command: drush pm-update.
- Finally, you just need to put your “freshly” updated Drupal 8 website back online and this is the command to type in Drush for triggering this action: drush sset system.maintenance_mode 0.
Et voila! Some simple commands to enter and a couple of quick essential steps to take and you're running the latest release of Drupal 8 on your website!
Update Your Drupal 8 Core Via Composer
This is, no doubt, the “speediest” method of them all!
Note: remember to backup (there! we've said it again!) and to use maintenance mode on production. Also, we, the OPTASY team, advise you to go for composer install rather than running your update on production!
And, of course, a few words about Composer: it's a package management tool, a truly powerful one, that you can use for managing your PHP based applications.
OK, now let's get back to our step-by-step guide on how to update your Drupal 8 core via Composer. Well, in fact, it's a “one step” procedure: simply enter the “composer update” command into your command-line interface and let it run the update for you:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Update Your Drupal 8 Core Manually
This is, indeed, the most tedious of all the 3 methods for you to update your Drupal 8 core with, but it's also the most thorough of them all.
And this is the sequence of steps involved:
- First, you go ahead and download the newest version of Drupal 8
- Next log in to your site's admin panel, either as a user having the “administer software update” permission or as an admin
- You make a backup of your database (for example through PHPMyAdmin)
- Once you have your database backup, you need to activate the maintenance mode (Administration > Configuration > Development > Maintenance mode), exactly like you would if you'd be using Drush instead
- Remove and then replace the vendor and the core directory from your website with the ones that you will have already downloaded upon downloading the latest version of Drupal 8: composer.lock, licence.txt, robots.txt, index.php, web.config, autoload.php.
Note: do not override your “older” directories with the new ones, as this will just cause a WSOD error!
- Remember to remove, also, all the files from your website's top-level directory. Keep the ones that you've manually added to your website, the ones that you've made changes to (like error log file, Google, Bing verification file). Do keep your modules, profiles, your themes, and site directories, as well!
- Upload the core directory from the new Drupal 8 version that you will have downloaded (see step 1!)
- Extract and copy the composer.lock, the composer.json and the .htaccess files from the newly downloaded version of Drupal 8
- Upload the “new” vendor directory to your website
- Head to yourwebsite'sdomainname.com/update
- Just follow all the on-screen instructions given to you there
And that's it!
As you can see for yourself, no matter which one of the three methods you might go for, updating your Drupal 8 core is no rocket science. It's no super complicated procedure that you, as a Drupal 8 website admin/owner can't perform it yourself.
Have you already tried any one of these methods? Have you encountered any unexpected errors? If so, do share your experience in the comments below so that we can identify the “culprit” and come up with a solution for your specific updating case!
We do Drupal development
Go to our Drupal page!