Skip to main content

How to Update Drupal 8 Core on a Linux Server

drupal 8 update core

Previously we published a post on how to install Drupal 8 on Ubuntu 16.04. Now this tutorial will show you how to properly update Drupal 8 minor version (8.x.x) on a Linux server. It doesn’t matter which Linux distro you are using, you can always use the following method to update Drupal 8 core.

Unlike WordPress, currently there’s no automatic way of updating Drupal 8. We have to update it manually. So without further ado, let’s get started.

Step 1: Back up Drupal Core and Database

It’s always important to have a backup. The Unix/Linux tar command line utility can help you back up a directory on your server.

tar -cpzf drupal8core.tar.gz /path/to/drupal/web/root

The above command will back up everything in your Drupal web root directory, compress them and save as a tarball. Of course you need to replace the red-colored text with the actual path to your web root directory. For detailed info of the tar command, check out man page (man tar).

To back up the Drupal Database, you simply need to execute the following one-liner, assuming you are using MySQL or MariaDB.

mysqldump -u root -p drupal-database > drupal-database.sql

Replace drupal-database with your actual database name which can be obtained with the below command.

mysql -u root -p -e "show databases;"

You may want to click here to see a detailed explanation on how to back up and restore MySQL/MariaDB database.

Step 2: Put the Site into Maintenance Mode

Login as the site admin which is also known as user 1 in Drupal. Then go to Manage > Configuration > Development > Maintenance mode.  Check the option and click Save configuration.

drupal 8 update put site into maintenance mode

Step 3: Delete Drupal Files and Directories

Use cd command to go into the Drupal 8 installation directory. Then delete core and vendor directories.

rm -r core/ vendor/

Do not touch any other directories. Next, we need to delete all remaining files in the Drupal 8 top-level directory. So now you have modules, profiles, sites and themes directories left on the server.

Step 4: Download the Latest Version of Drupal 8

Download the new version of Drupal core from Save it to a directory outside the Drupal installation. You can use wget to download it from the command line like below. You may need to replace with version number.


Then extract the file.

tar xvf drupal-8.1.8.tar.gz

A new directory drupal-8.x.x will be created in the current directory. Cd into that directory.

cd drupal-8.1.8

Before we copy these files and directories into the Drupal installation directory. we need to delete modules, profiles, sites and themes directories because we do not want the four directories be rewritten. If they are rewritten, then you custom modules, theme and stuff like that will be lost.

rm -r modules/ profiles/ sites/ themes/

Then we can copy all remaining files and directories to the Drupal installation directory.

cp -R * .htaccess /path/to/Drupal/web/root/

Step 5: Update Drupal Database

Now that Drupal core is updated, we also need to update Drupal database by visiting
Drupal 8 database update

Click the Continue button.

If you user Nginx and encounter an error like update.php/selection page can not be found. Then add the following location block to your Nginx config file and reload Nginx.

location ~* ^/update.php {
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_pass unix:/run/php/php7.0-fpm.sock;
  fastcgi_index update.php;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root/update.php;
  fastcgi_param SCRIPT_NAME /update.php;

If the database update is successful, then you will see the following message.

No pending updates.

Step 6: Switch from Maintenance to Online Mode

After Drupal 8 database update is complete, go to Manage > Reports > Status report. Verify that everything is working.

Then go to Manage > Configuration > Development > Maintenance mode. Uncheck the box and save your settings.

Your Drupal site is out of maintenance mode and you have successfully updated Drupal 8.

Final Thoughts

And now you can see why Drupal is not for newbie bloggers or webmasters. It’s such as pain compared to WordPress update which allows you to push a button and in a few seconds you’re done updating.

Anyway it’s very important to update your Drupal site ASAP to prevent malicious hacking.

And as always, if you found this post useful,  subscribe to our free newsletter or follow us on Google+Twitter or like our Facebook page.

Rate this tutorial
[Total: 1 Average: 5]