updates

Very often, Drupal releases security patches and asks webmasters to update drupal sites. This is another strong reason that you shall use ‘composer’ to install your Drupal site in the first place. If your Drupal site is not installed by composer, you may follow How to Install Drupal 10 to install one.

1. Show Available Update

Go to the directory you installed drupal. It should contain composer.json and the directory of web. The following command will let you know whether there is any update available.

sudo -u www-data composer outdated "drupal/*"
Composer Outdated
Composer Outdated

2. Backup your Site

If you run a live site, it’s critical to back up your site before updating. Please refer to ‘Concept: Data Backups‘ and ‘Making a Development Site‘ for how to back it up, including site configuration, customized theme and module, and database.

3. Perform Drupal Update

3.1 Enable update_free_access

Open settings.php (/sites/default/settings.php), and change update_free_access to True.

$settings['update_free_access'] = TRUE;

3.2 Put Site into Maintenance Mode

Navigate to Administration->Configuration->Development->Maintenance mode. Check the checkbox in front of ‘Put site into maintenance mode’.

Maintenance mode Configuration
Maintenance mode Configuration

3.3 Update Drupal Core File

If any update is available, use the following command to perform the update.

sudo -u www-data composer update "drupal/core-*" --with-all-dependencies
Composer Update
Composer Update

You may simulate the update, and show you what would happen, without actually changing anything, add --dry-run.

3.4 Update Drupal Database

Composer only updates the core files, but not the database. You’ll need to visit https://yourhost.name/update.php and follows the instruction to finish the database update as well.

database update
Database Update

3.5 Disable update_free_access and Maintenance Mode

Reverse what you have done in 3.1 and 3.2 to disable update_free_access and take the site out of maintenance mode.

4. Further Reading on Update Drupal

For further reading, please refer to Update Drupal Core via Composer and Update the Core.

Please switch to composer installation, if you have not. When you update and resolve dependencies, it’ll save you lots of time and effort.

Leave a Reply

Your email address will not be published. Required fields are marked *