13.5. Updating the Core Software
- If you want to use Drush, Drush must be installed. See 第 3.2 节 “Concept: Additional Tools”.
- If your site is live, you should test this process in a development environment before running it on your production site. See 第 11.8 节 “Making a Development Site”.
- Make a complete backup of your site. Refer to 第 12.3 节 “Concept: Data Backups”.
Open settings.php (/sites/default/settings.php) in any plain text editor. Find the line with the $settings[update_free_access] variable. By default, it is set to "FALSE" due to security reasons. Change the setting to "TRUE":
$settings['update_free_access'] = TRUE;
- Disable any caching technique (memcache, varnish, and so on) your application might be using.
- Put your site in maintenance mode. See 第 11.2 节 “Enabling and Disabling Maintenance Mode”.
- If you are using Composer to manage dependencies, or using Git, skip the next six steps, and instead see 第 11.9 节 “Using Composer and Git to Download Files” for instructions on downloading updated files. Continue with the update.php step.
- Download the tar.gz or zip file archive for the latest version of Drupal 8.x core from Drupal.org Drupal Core Downloads. See 第 3.3 节 “Preparing to Install” for more details on how to find the latest version.
- Upload the archive file to your web hosting server.
Extract the archive file to a temporary directory on your server (should be outside the directory where the site is hosted). Your hosting control panel’s file manager should provide a way to extract the files. Or, if you have terminal access to your hosting server (running Linux), you can use a command like:
tar -xzf drupal-8.3.2.tar.gz
You can also use Drush to download the archive and extract it in one step, by navigating to the temporary directory on the server and entering this command:
drush dl drupal
- In your site hosting directory, delete the core and vendor directories, and all files that are not in a subdirectory, including .htaccess, composer.json, and autoload.php. Don’t delete custom and customized files because you may end up losing the custom functionality stored in them.
- Copy the core and vendor directories and the non-custom/non-customized files that you deleted in the preceding step from the temporary directory to your site directory.
Run the update.php script using either of the following:
- Visit http://www.example.com/update.php in your browser (where www.example.com is your site’s URL). Click Continue in the first screen to run the updates and successfully complete the script.
-
Run the following Drush command:
drush updb
- If you get any error or warning, re-run the update.php script again till all the updates have been completed successfully.
Open settings.php (/sites/default/settings.php) in a text editor. Find the line with the $settings[update_free_access] variable and update it to "FALSE":
$settings['update_free_access'] = FALSE;
- Click Administration pages to return to the administration section of your site.
- Take your site out of maintenance mode. See 第 11.2 节 “Enabling and Disabling Maintenance Mode”.
- Clear the cache. See 第 12.2 节 “Clearing the Cache”.
- Re-enable any caching technique you disabled at Step 3.
- You should have the updated version running. You can verify the current version of your software by checking the Status report (see 第 12.5 节 “Concept: Status Report”).
- "Drupal Core Downloads" page on Drupal.org
- "Registry Rebuild" page on Drupal.org
- The file /core/UPDATE.txt within your installation.
Attributions
Written and edited by Surendra Mohan, Boris Doesborgh, and Jojy Alphonso at Red Crackle.
Source file: security-update-core.asciidoc
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion