Update procedure in Drupal 8
Firstly, make sure you understand the difference between update and upgrade.
To update from one 8.x.x version of Drupal to any later 8.x.x version, do the following:
Before you begin
Always take a backup of your files and db before updating.
Easiest way to do this:
- Read the release notes.
If you're using Composer, you can skip all of the following and just run
composer update. However you should still backup and consider activating maintenance mode on production. (It's normally appropriate to use
composer install rather than update on production, too, to exactly replicate your dev environment.)
If you're using Drush, you can also skip all of the following steps and just run
drush up drupal. As stated above, make a back-up and use maintenance-mode.
Log in as a user with the permission "Administer software updates".
In the command line (shell), navigate into your drupal installation:
Put site into maintenance mode
Via admin interface:
Go to Administration > Configuration > Development > Maintenance mode.
Check "Put site into maintenance mode" checkbox and click Save Configuration.
Or via drush:
drush sset system.maintenance_mode 1 drush cr
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.
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:
- 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.
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.
On a typical Unix/Linux command line, use the following commands to download and extract:
wget https://www.drupal.org/files/projects/drupal-x.y.z.tar.gz tar -zxvf drupal-x.y.z.tar.gz
This 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/installation
If 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.
- Re-apply any modifications to files such as .htaccess, composer.json, or robots.txt.
- If using Composer to manage PHP libraries, update your /vendor directory with the following command:
composer update drupal/core --with-dependencies
If you are unable to access update.php do the following:
- 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
- Go to Administration > Reports > Status report. Verify that everything is working as expected.
- Ensure that $settings['update_free_access'] is FALSE in settings.php.
Go to Administration > Configuration > Development > Maintenance mode. Disable the "Put site into maintenance mode" checkbox and save the configuration.
Or via drush:
drush sset system.maintenance_mode 0 drush cr
11.By update via the Drupal Console.Use the below command
$ drupal self-update [options]
Update to a new major version, if available.
Override the manifest file path.
Override the version to update from.
12. 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/