The Dev (and Test) hosts were built on Ubuntu 20.04 LTS using PHP 7.4 which is now out of support. While this is not that much of an issue given the systems are not exposed to the internet with the release of Joomla 4.3.0 it's a good time to bring them back into line with the Live site.

At the same time I'm also going to change from using PHP through the Apache2 mod_php to using the PHP-fpm service, again to bring it in to line with the hosting provider, Mythic Beaasts, so that I will hopefully see any issues well in advance.

As always before starting changes that might get interesting, the first step is to take a backup. Since this is running on my Geeklab, I can use a VM snapshot. While this need a short outage, it means restore are also very fast as well. And if it works I can release the snapshot.

Components Start Version End Version
Linux Ubuntu 20.04 LTS Ubuntu 20.04 LTS
Apache 2 Apache 2.4.41 Apache 2.4.41
MariaDB 10.3.38 10.3.38
PHP 7.4.3 apache2handler 8.1.18 fpm-fcgi
Joomla 4.2.9 4.2.9

 

It also helps that I've just been through a similar process with my in-house Nextcloud servers servers.

The first task was to apply the latest Ubuntu patches using apt upgrade and a quick check there's no issues with disk space and that Joomla is also running nicely too. We do not want to do an upgrade once the PPA is added untill we've finished this.

Enable the PHP 8.1 repository

Ubuntu 20.04 does not have PHP 8.1 in any of the standard repositories. Ondej Sury packages PHP for Debian and kindly maintains a PPA for Ubuntu too which makes it so much simpler to install.

sudo apt-add-repository ppa:ondrej/php
sudo apt update

Done. So much easier than messing with .list files.

Install PHP 8.1 Packages for Joomla

The PPA will try to install PHP 8.2 given a chance and I do not want to do this yet, at least untill Mythic Beasts provide the option for the live site, so I'm going to install the php8.1- specific versions rather then just update to the latest automatically. Before allowing each update to proceed check the package it's going to install, plus any dependencies.

A quick way to check what's currently there is to ask apt. And hopefully this still matches the list in the documentation you prepared while installing it it. I thought so.

apt list --installed | grep php

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libapache2-mod-php7.4/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php-common/focal,now 2:75 all [installed,automatic]
php-curl/focal,now 2:7.4+75 all [installed]
php-gd/focal,now 2:7.4+75 all [installed]
php-intl/focal,now 2:7.4+75 all [installed]
php-mbstring/focal,now 2:7.4+75 all [installed]
php-mysql/focal,now 2:7.4+75 all [installed]
php-xml/focal,now 2:7.4+75 all [installed]
php-xmlrpc/focal,now 2:7.4+75 all [installed]
php-zip/focal,now 2:7.4+75 all [installed]
php7.4-cli/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-common/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-curl/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-gd/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-intl/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-json/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-mbstring/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-mysql/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-opcache/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-readline/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-xml/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-xmlrpc/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4-zip/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 amd64 [installed,automatic]
php7.4/focal-updates,focal-security,now 7.4.3-4ubuntu2.18 all [installed,automatic]
php/focal,now 2:7.4+75 all [installed]

 

sudo apt install php8.1-fpm

This will also bring in php8.1-cli, php8.1-common, php8.1-opcache and php8.1-readline

Then install the other required modules.

sudo apt install php8.1-curl php8.1-gd php8.1-intl php8.1-mbstring php8.1-mysql php8.1-xml php8.1-zip

The php8.1-xmlrpc package requests to bring in some php8.2 package which I don't want. As I can't find any specific need for this I'm not going to install it.

Switchover

We now need to reapply the customisations we made to the original php.ini file. The old one will still be at /etc/php/7.4/apache2/php.ini and the new one will be at /etc/php/8.1/fpm/php.ini. You can compare both files, but if you've been keeping records of any changes it there should just be the two usual ones it warns about under installation messages.

post_max_size = 16M
upload_max_filesize = 16M

And now we can disable PHP 7.4

sudo a2dismod php7.4

And then enable PHP 8.1

sudo a2enmod proxy_fcgi
sudo a2enconf php8.1-fpm
sudo systemctl start php8.1-fpm
sudo systemctl restart apache2

And now login in as an administrator and on the Home Dashboard page you shouldn't be able to see that huge red banner warning about PHP 7.4 being obsolete any more.is now missing. And System > System Information should now show PHP 8.1.18.

Remove old version

As we no longer need the old Ubuntu-supplied PHP packages they should be removed, not just to reduce clutter but as one of the reasons for the upgrade is the ending of security patches it would be very difficult for somebody to exploit a 7.4 bug if it's no longer installed. Check the list of packages to be removed each time before allowing the command to continue, just to be sure it's not about to do something silly.

sudo apt remove php

sudo apt remove php-curl php-gd php-intl php-mbstring php-mysql php-xml php-xmlrpc php-zip

sudo apt remove php7.4-common

sudo apt autoremove

A final check of what's still installed should show just php8.1 packages

sudo apt list --installed | grep php

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

php-common/focal,now 2:75 all [installed,upgradable to: 2:93+ubuntu20.04.1+deb.sury.org+2]
php8.1-cli/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.1-common/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.1-curl/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-fpm/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-gd/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-intl/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-mbstring/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-mysql/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-opcache/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.1-readline/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.1-xml/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-zip/focal,now 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]

And we can update php-common to Sury's version with a final upgrade.

sudo apt upgrade

And we're done. The PHP 7.4 configuration files are still in /etc/php/7.4 and may be worth holding onto for a few weeks just in case of any issues, but add a note to your diary to purge them.

Aftermath

I need to repeat the process on the Test host and that'll complete the PHP true-up with the Live instance. Then it's time to try out Joomla 4.3 and see what's new.

And of course I need to release the snapshot I took at the start once the normal backup has completed.

Curiously I've now found that php8.1-xmlrpc will now install without wanting to bring in any php8.2 packages. I'm going to wait until I find proof it's needed though.