Skip to content

How to update Drupal and Drupal modules

Beautiful Canoe has a small number of Drupal based websites. These will periodically send an email with the subject line New release(s) available for to to say that updates need to be applied to the sites. This is a security concern, and updates should be applied as quickly as possible.

Log into the Drupal admin site

Login to the relevant site using its Drupal admin URL, e.g. Note that in many Drupal sites there is no link within the site to log in as an administrator -- you just have to know the URL. If you don't have an account on a Drupal site, and you believe you need one, please speak to either @snim2 or @a.garcia-dominguez.

Updating Drupal modules

Most update notifications apply to Drupal modules. If you need to update drupal core itself, skip this section and see the instructions below.

Finding the right module to update

Click on the the Modules link on the navigation bar at the top of the site. On the overlay that pops up, you will see a link in a block of text that starts: Regularly review and install available updates to .... Click on the available update link (there is a similar one elsewhere, but it doesn't work on all versions of the Drupal admin page).

Scroll down the list of modules to find the one that needs updating. It may be possible to update the relevant module automatically, but if not, copy the link to the relevant .tgz file.

Updating modules on the server

ssh to the relevant server. You should be able to log in with your normal Aston credentials, but if not please speak to either @snim2 or @a.garcia-dominguez.

In your home directory, download the module (paste the URL you copied from the Drupal admin site):

wget URL

Then you need to find the latest install of Drupal:

$ cd /var/www
$ ls
dev ... html live portal-7.32 portal-7.59 portal-7.60 portal-7.61 ...
$ # In this case 7.61 is the latest version number
$ cd portal-7.61

Now, cd to the modules directory:

cd sites/all/modules

Replacing the old module with a new one

Move the old module to /tmp/ or similar, and replace it with the new version that you downloaded to $HOME. You will probably have to use sudo, e.g.:

sudo mv OLD-MODULE /tmp/
sudo tar -xvzf ~/NEW-MODULE.tgz

Change file ownership

Next, because you used sudo above, the new module files will be owned by root, which is a security risk. Make sure you change them:

sudo chown -R www-data.www-data NEW-MODULE/*

Check that updating the module worked

Go back to the Drupal admin web page, and refresh the list of modules. Check that the one you have replaced is now shown as Up to date.

Updating Drupal core

Check that the site has been automatically backed up

Before you update Drupal, make sure that your site and its database has been backed up.

Check /var/backups to see if the Drupal instance has been automatically backed up. Check /etc/cron.daily/PROJECT to see if the site database has been automatically backed up. Check /etc/logrotate.d/sql-backups to ensure that database backups are being rotated.

ssh to the relevant server. You should be able to log in with your normal Aston credentials, but if not please speak to either @snim2 or @a.garcia-dominguez.

In your home directory, download the recommended version of Drupal (paste the URL you copied from the Drupal admin site) and extract the files in the tar ball:

wget URL
tar -xvzf ~/drupal-VERSION.tar.gz

Change the owner of the Drupal files recursively:

chown -R www-data.www-data drupal-VERSION

Move the new version of Drupal to the /var/www/ folder:

sudo mv drupal-VERSION /var/www/portal-VERSION
cd /var/www/portal-VERSION

Rename the sites directory to sites-default:

sudo mv sites sites-default

Copy over the old sites folder from the current Drupal instance and change file permissions:

sudo cp -R ../portal-LAST-VERSION/sites sites
cd sites/default
sudo chown www-data:gitlab-runner settings.php
sudo chown -R www-data:gitlab-runner files
sudo chmod g+s files
find files -type d -exec sudo chmod g+w '{}' \;

Maintenance mode

At this stage, you should already have logged in to the relevant site using its Drupal admin URL, e.g., but if not, do that now.

To set your site on maintenance mode, first go to then look for the Development heading, and click on the Maintenance mode link underneath:

Select maintenance mode

Click on the checkbox labelled Put site into maintenance mode and save the configuration:

Set maintenance mode

Do not log off from the website.

Update Apache

cd /etc/apache2/sites-available
sudo vim portal.conf

Edit the file to update the version number of Drupal -- note the two instances of VERSION in the example file below:

<VirtualHost _default_:443>
  DocumentRoot /var/www/portal-VERSION
  ServerName ...
  ServerAlias ...
  SSLEngine on
  Include /etc/letsencrypt/options-ssl-apache.conf

  ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/opt/phpbrew/php/php-5.6.35/var/run/php-fpm.sock|fcgi://localhost/var/www/portal-VERSION/

  SSLCertificateFile ...
  SSLCertificateKeyFile ...

<VirtualHost _default_:80>

Reload Apache:

sudo service apache2 reload

Update Drupal

Run update.php by navigating to and follow the process to update your Drupal instance.

Disable maintenance mode

Disable maintenance mode by going to and following the same process you used for setting maintenance mode.

Check the new site configuration

Go to and check that there are no further warnings or errors.

Go to and check whether any more modules need to be updated.

Further reading

The Drupal project provides documentation for updating Drupal 7. Similar documentation is available for Drupal 8.