Update procedure in Drupal 8
  • Facebook
  • Twitter
  • LinkedIn

Last updated on

November 24, 2016 – 21:19

To update from one 8.x.x version of Drupal to any later 8.x.x version, do the following:

Important

  1. Take backup of files and db before update.
  2. Read the release notes before doing Update security.

Steps

Log in as a user with the permission “Administer software updates”.

  1. In the command line (shell), navigate into your drupal installation:cd /path/to/your/installation
  2. Put site into maintenance mode through the Drupal admin interface. Go to Administration > Configuration > Development > Maintenance mode. Enable the “Put site into maintenance mode” checkbox and save the configuration.drush sset system.maintenance_mode 1 drush cr
  3. Or via drush:
  4. Remove the ‘core’ and ‘vendor’ directories. Also remove all of the files in the top-level directory, except any that you added manually.rm -rf core vendor rm -f *.* .*If you made modifications to files like .htaccess, composer.json, or robots.txt, back them up now – you will need to re-apply them from your backup, after you’ve installed the new Drupal core.  For example, Acquia Dev Desktop places a .htaccess file in the top-level directory and without it, only the homepage on your site will work.
    • Locate your settings.php file in the /sites/* directory. (Typically sites/default.)
    • Make a backup copy of your settings.php file, with a different file name.
    • Make a copy of the new default.settings.php file, and name the copy settings.php (overwriting your previous settings.php file).
    • Copy the custom and site-specific entries from the backup you made into the new settings.php file. You will definitely need the lines giving the database information, and you will also want to copy in any other customizations you have added.

    You can find the release notes for your version at https://www.drupal.org/project/drupal. At bottom of the project page under “Downloads” use the link for your version of Drupal to view the release notes. If your version is not listed, use the ‘View all releases’ link. From this page you can scroll down or use the filter to find your version and its release notes.

  5. Sometimes an update includes changes to default.settings.php (this will be noted in the release notes). If that’s the case, follow these steps:
  6. Download the latest Drupal 8.x.x release from https://www.drupal.org to a directory outside of your web root. Extract the archive and copy the files into your Drupal directory.wget https://www.drupal.org/files/projects/drupal-x.y.z.tar.gz tar -zxvf drupal-x.y.z.tar.gzThis creates a new directory drupal-x.y.z/ containing all Drupal files and directories. Copy the files into your Drupal installation directory :cp -Rf drupal-x.y.z/* /path/to/your/installation cp -f drupal-x.y.z/.* /path/to/your/installationIf you do not have command line access to your server, download the archive from https://www.drupal.org using your web browser, extract it, and then use an FTP client to upload the files to your web root.
  7. On a typical Unix/Linux command line, use the following commands to download and extract:
  8. Re-apply any modifications to files such as .htaccess, composer.json, or robots.txt.
  9. If using Composer to manage PHP libraries, update your /vendor directory with the following command:
    • composer update drupal/core –with-dependencies
  10. Run update.php by visiting http://www.example.com/update.php (replace www.example.com with your domain name). This will update the core database tables.
    • Open settings.php with a text editor.
    • Find the line that says:
      $settings[‘update_free_access’] = FALSE;
    • Change it into:
      $settings[‘update_free_access’] = TRUE;
    • Try again to run update.php.
    • Once the update is done, $settings[‘update_free_access’] must be reverted to FALSE.

    Or via drush:drush updb drush entup

  11. If you are unable to access update.php do the following:
  12. Go to Administration > Reports > Status report. Verify that everything is working as expected.
  13. Ensure that $settings[‘update_free_access’] is FALSE in settings.php.
  14. Go to Administration > Configuration > Development > Maintenance mode. Disable the “Put site into maintenance mode” checkbox and save the configuration.drush sset system.maintenance_mode 0 drush cr
  15. Or via drush:

11.By update via the Drupal Console.Use the below command

$ drupal self-update [options]

Option Details
–major Update to a new major version, if available.
–manifest Override the manifest file path.
–current-version Override the version to update from.
  1. After updating, you can remove the Drupal release you downloaded and extracted earlier:

rm drupal-x.y.z.tar.gz rm -rf drupal-x.y.z/