Drupal Secure Full Version Update Guide with Composer + Drush (Complete Tutorial Composer is the officially recommended dependency management tool for Drupal, and Drush is a dedicated command-line tool for Drupal. The combination of the two enables secure and efficient updates of the Drupal core, modules, and themes to the latest stable versions. This tutorial applies to all Drupal 8/9/10/11 sites built with Composer. All operations are performed via the command line, avoiding security risks and file conflicts caused by manual updates.
1. Pre-update Preparation (Mandatory for Site Security)
1.Back up full site data: Back up the website database and site root directory files to quickly roll back if exceptions
2. Enable maintenance mode: Disable front-end access during updates to prevent data errors
3. Clear cache: Clear Drupal cache in advance to reduce update conflicts.
drush set system.maintenance_mode 1
# Clear
dr
Run commands to check the current version and available updates of Drupal core and extensions, confirm the components to be updated, and avoid blind upgrades.
# Check all available updates (core
drush pm
# Check Drupal core
drush core:status
3. Update Core and Extensions via Composer
Enter the Drupal root directory and run Composer commands to pull the latest versions of core files and dependency packages, which is the core update step. The commands automatically adapt to version dependencies and ensure file integrity.
# Update Drupal core to the latest
composer update drupal/core --
# Update all installed modules and themes to the latest versions
composer update
Do not close the terminal during execution. The update of files is completed when the "Success" prompt appears.
4. Perform Database Updates via Drush (Critical Step)
After file updates are completed, database updates are mandatory to synchronize the fields, configurations, and table structures of the new version; otherwise, the site will report errors and become inaccessible.
# Execute database updates (enter y to confirm when prompted
dr
# Clear all
drush cr
5. Disable Maintenance Mode and Complete the Update
After the database update is finished, disable maintenance mode to restore normal site access, and verify the normal operation of front-end and back-end functions.
#
drush set system.main
# Check the final
drush core:status
6. Post-update Inspection and Common Issues 1. Access the site front-end and back-end to confirm the normal display of pages, functions and
2. In case of a white screen, re-run the cache clearing command: dr
3. In case of permission abnormalities, reset permissions: drush php-eval 'user_access_rebuild()
Summary: Updating Drupal with Composer + Drush is the official standard solution, featuring safety, stability and automation. Regular updates can fix vulnerabilities, improve performance and unlock new features. It is recommended to check and update versions monthly to ensure the stable operation of the site.
Comments