Content
Introductory
Drupal 9 CMS system already several base system updates have been released in recent weeks, so you might want to review this update mechanism as well as before Update Drupal 8 in the case of. In this description, a Debian 10 (Buster) for a perfect server installed Drupal 9 website i will be upgrading from 9.1.2 to 9.1.4 so here we are now jumping to multiple versions at once. There are two ways to do this: first composer, and then look at the manual update.
Check for updates
In the admin interface of the Drupal based website if you enter Expansion main menu, you will see a warning that another base system update has arrived:
Here is a link that takes us to the available updates page:
So here we can see that our version is currently 9.1.2 and that 9.1.4 is already available, so it is recommended to upgrade to this.
Unfortunately, the base system update cannot be solved with 1-2 clicks like a module update, but has to be done manually. If you click on the Release Information link, you will be taken to the English language page of Drupal, where you can see the contents of the update package in full detail. This update is just a fix pack, so we don't expect any complications right now.
Create a backup
Also, if we have the ability, we do not perform the update on a live website, but in the development environment, which we can then upload to the hosting after verification. If we do not have the opportunity to do so, we will perform the update very carefully!
Update methods
The Drupal offers several ways to upgrade your system, in this description, we update using the following methods:
- Upgrading your Drupal 9 base system using Composer
- Manually upgrade Drupal 9 base system
The two methods can be applied independently, I perform both on the same server state
Upgrading your Drupal 9 base system using Composer
A Compose is a PHP-based package manager that Drupal relies heavily on. For example, many modules can only be installed using this, not via the web. So if you have already used Composert in your Drupal system to install modules, this is the recommended upgrade method. Furthermore, Drupal is recommended for the following users this update method:
- Familiar with Drupal updates
- Interested in using Composer command line operations
- If a command is not available in Composer, Drush you can also use a program
- Has shell access to the website
Things you need to upgrade to Composer:
- Shell access
- Existence of a Composer package manager (Installation guide)
- Existence of Drush (Installation guide)
- Go existence of a version control system
Drupal recommends this upgrade method, and I prefer it myself. The official Drupal update description of this can be found here.
Check conditions before upgrading
Before starting the upgrade, use the shell user who manages your Drupal 9-based website to log in to the website's root directory and check things out:
composer --version
vendor/bin/drush --version
vendor/bin/drush status
So we’re in the web root directory of the website (this is important because of Composer!), We have Composer and we also have drush, and drush also displays the appropriate information about our instance of Drupal, such as the base system version, and so on.
The next step is to make sure your Drupal page is ready to use Composer. To do this, run the following composer command from the web root:
composer show drupal/core-recommended
A drupal / core-recommended a metapackage that provides Drupal base system functionality and even adds Composer functionality to make the site manageable with the PHP package manager (see the project for more details) GitHub site located). After running the command, if the package is OK, we should get something like this:
This package is part of the base system for Drupal 9, so it is present with almost complete certainty.
Save individual files
Drupal overwrites the entire system during the upgrade, including files in the web root directory and occasionally configuration files. Therefore, if you have files that you have modified manually in the meantime, save them. Examples include the following files:
- .htaccess
- robots.txt
- composer.json
- sites / default / settings.php
Of these, for example, a We have already made changes to the settings.php file immediately after installing Drupal, so we definitely already have custom settings in this. These changes should be checked after the upgrade and then re-applied to the updated files if necessary. Settings.php is not usually overwritten, but there are update releases that also modify this file, in which case it will overwrite the existing one, so you may want to save this before upgrading. Of course, if we made a full backup at the beginning, we can also restore our own changes from it later. See the descriptive page for that update to see what files have changed.
If there has been a change in the composer.json file during a more recent release, and you have already made manual changes to your own file, then you need to merge the composer.json files more thoroughly. About this earlier, Drupal 8 in my upgrade guide I wrote in detail so we can find out more about this.
Turn on maintenance mode
If you are updating on a live website, you must first turn on maintenance mode so that other users cannot modify the page during the update. You can also do this in the admin of the website a Setting main menu Development on the panel Maintenance mode by clicking on the option:
Or, if you're already on the command line, use the following drush commands:
vendor/bin/drush state:set system.maintenance_mode 1
vendor/bin/drush cache:rebuild
Update
To upgrade the base system, run the following command:
composer update drupal/core "drupal/core-*" --with-all-dependencies
Then we even need to update the database:
vendor/bin/drush updatedb
Not always here, but if prompted, press enter to perform updates. Then he also tells us the status of success.
Restore individual files
If we have made individual changes to the files mentioned above, we will repeat them again. The easiest way to use the diff command is to combine instances of the old and new files, based on the output of which we can easily restore our own changes. To use the diff command:
diff <régi lementett fájl> <új fájl, amivel felülírtuk a tárhelyen>
Where the files can be any of the above mentioned .htaccess, robots.txt, settings.php, etc. files.
Disable maintenance mode and rebuild cache
To turn off maintenance mode and rebuild caches, run the following two commands:
vendor/bin/drush state:set system.maintenance_mode 0
vendor/bin/drush cache:rebuild
Control
The update is complete, we will now check that everything is OK.
Let's first look at the command line:
vendor/bin/drush status
Here you can see the basic system version 9.1.4 as well as the other data.
Now let's take a look at the admin of the website:
Everything is fine here too.
Manually upgrade Drupal 9 base system
You can upgrade the Drupal base system without using the composer and drush commands. In this case, you need to manually download the update package and copy it to its location. This update method is recommended for the following users who:
- They are not yet familiar with Drupal updates
- They don't have shell access, so that's it FTPcan access the file structure of the website via
- They have shell access but have no way or don’t want to use the composer and drush commands
A manual update requires at least one of the following:
- Shell access
- FTP access if there is no Shell access
If you are upgrading in a shell, log in with the shell user who manages your Drupal 9 website, that is, the user who owns the files and directories on the website. If you use FTP, we also use the FTP account created for the website.
Save individual files
When you copy the Drupal installation package to storage, it overwrites the entire system, including the files in the web root directory and occasionally the configuration files. Therefore, if you have files that you have modified manually in the meantime, save them. Examples include the following files:
There may be updates that also change files in which we have changed something ourselves. In this case, these changes must be made again at the end of the update. Therefore, it is recommended that you save the following files separately before upgrading:
- .htaccess
- robots.txt
- sites / default / settings.php
Of these, for example, a We have already made changes to the settings.php file immediately after installing Drupal, so we definitely already have custom settings in this. These changes should be checked after the upgrade and then re-applied to the updated files if necessary. Settings.php is not usually overwritten, but there are update releases that also modify this file, in which case it will overwrite the existing one, so you may want to save this before upgrading. Of course, if we made a full backup at the beginning, we can also restore our own changes from it later. See the descriptive page for that update to see what files have changed.
Turn on maintenance mode
If you are updating on a live website, you must first turn on maintenance mode so that other users cannot modify the page during the update. You can also do this in the admin of the website a Setting main menu Development on the panel Maintenance mode by clicking on the option:
Here, in addition to switching to maintenance mode, this step is also important because we need to log in as admin, which will be needed to run database updates later. So be sure to log in as admin so that our browser will "recognize" us.
Update
The update consists of a more complex sequence of operations by hand, so it is clearer with additional subheadings.
Remove system files
In this step, we remove the files that are part of the base system:
- core / and vendor / subdirectories, and
- files in the web root
These files and directories do not contain any unique or personal settings because they remain above modules /, profiles /, sites / and themes / are in subdirectories, so all our settings will remain on the website.
Shell use
To perform the deletion, go to the web root directory of your Drupal 9 based website and run the following commands:
rm -rf core vendor
rm -f *.* .[a-z]*
The first command deletes that core / and vendor / directories, leaving everything else in place, and the second command deletes all files from the web root directory.
After deleting, our web root directory will look like this:
FTP usage
In FTP, navigate to the root directory of the web page and delete core / and vendor / subdirectories and all files from the web root. Make sure that the modules /, profiles /, sites / and themes / do not delete subdirectories.
Download, extract, and copy an update package
In this step, we download the latest Drupal 9 installation package, unzip it, and copy the necessary files and directories into place.
In this example, I am downloading the Drupal 9.1.4 installation package, which is currently the latest. Of course, when reading the description later, we will use the latest version, so replace your own version. Updates to Drupal 9 can be found here: www.drupal.org/project/drupal/releases?version=9
Shell use
Create a temporary directory for the update, which you can even create in the web root, say a update / called a subdirectory, so we can move more conveniently between the web root and between. So run the following command from the web root:
mkdir update
Then go to the directory, then download and unpack the latest installation package. For me, 9.1.4 will be:
cd update
wget https://ftp.drupal.org/files/projects/drupal-9.1.4.tar.gz
tar -xzf drupal-9.1.4.tar.gz
Go to the created directory:
cd drupal-9.1.4/
And copy the core / and vendor / subdirectories and files in the directory to the web root two directory levels away:
cp -R core vendor ../../
cp *.* .[a-z]* ../../
Then exit the directory and delete the excess:
cd ../..
rm -rf update
FTP usage
If you use FTP, use the browser to download the latest installation package to your computer, for example, 9.1.4 in the format we like best for us (tar.gz or zip), then unzip it and upload it to the web root. core / and vendor / subdirectories as well as all files from the main directory of the extracted archive.
Restore individual files
If we have made individual changes to the previously mentioned files, we will repeat them again on the newly copied files. The easiest way to use the diff command is to combine instances of the old and new files, based on the output of which we can easily restore our own changes. To use the diff command:
diff <régi lementett fájl> <új fájl, amivel felülírtuk a tárhelyen>
Where the files can be any of the above mentioned .htaccess, robots.txt, settings.php, etc. files.
Database update
Use your browser to go to /update.php on the website:
http(s)://www.drupalosoldal.tld/update.php
With me:
It’s important here now that we’ve logged in as admin before, because otherwise it wouldn’t let us into the updater. If this happens because we missed the admin login at the beginning, open the settings.php our file, which by default is sites / default / is under the directory and look for the following line:
$settings['update_free_access'] = FALSE;
And set to true:
$settings['update_free_access'] = TRUE;
(You can change this from both shell and FTP.)
Then visit the update.php file again. At the end of the upgrade, don't forget to reset this setting to FALSE!
So if the update has started, after reading the info that appears here, click on Continuation button. Then, on the next page, list any database updates:
Click here Apply pending updates button. The progress bar then goes through and enters the last panel:
Here, if there are no errors, you can also go to the admin of your Drupal 9 system to look around.
Turn off maintenance mode
Finally, turn off the maintenance mode, a Setting main menu Development on the panel Maintenance mode by clicking on the option:
Here, uncheck the box and click Save settings button.
Control
The update is complete, we will now check that everything is OK. Enter the Reports main menu Status report menu item:
As you can see, the page is up to date and in perfect condition with the help of the manual update.
Conclusion
Here we could see two ways to upgrade so everyone can decide which one is more comfortable and sympathetic to them. Of these, I recommend the composer upgrade, because once you have met the conditions, the upgrade process is very simple and fast from there. Also, if you start using the composer over time and install modules with it, only this upgrade mode will work from the start.
- Installing and setting up Drupal 9 CMS system
- Upgrading your Drupal 8 base system easily
- Upgrading the Drupal base system to 8.8
- Encyclopedia - Composer
- Encyclopedia - Drush
- What to do if the Composer PHP package manager is running very slowly, stumbling while updating projects
- How to remove index.php parts from the URLs of our Drupal based CMS system
- drupal.org - Docs - Updating Drupal core via Composer
- drupal.org - Docs - Updating Drupal core manually
- To post registration and login required
- 181 views