Nextcloud – Upgrading to Ubuntu 22.04

I’m running four Nextcloud instances, all of them in separate virtual machines on Ubuntu 20.04. The problem: Ubuntu 20.04, despite still being rather young, comes with PHP 7.4, which has been declared end of live recently, and Nextcloud has announced that they will no longer support this PHP version in their next release. So while I would probably still have a year or so to do something about this, I’ve decided to be proactive and do a release upgrade of the operating system to Ubuntu 22.04, which includes the latest and greatest PHP version (8.1) at the time of writing. As expected, there were a few bumps along the way and the Apache web server installation on all instances needed some manual tweaking after the OS upgrade. The interesting touch: Even though the virtual machine images were very similar, each Apache installation required a different nudge.

Virtual Machine 1

On the first virtual machine, Apache looked like it was pretty much completely broken after the update to Ubuntu 22.04. On startup, it always complained about an invalid parameter in the config file at a line that was definitely correct. After a bit of fiddling, I decided to do a 360, purge Apache and install it again. After enabling the required modules and sites, I modified some lines in the config files again (which are non-standard in my installation), and Nextcloud came up again. Still, a bit scary to purge Apache and reinstall it from scratch again after an OS upgrade. Only when I was upgrading the third virtual machine would I find out what the reason for this odd error was.

On a bare metal server without an easy way to recover, such an action would have worried me. On virtual machines, however VM snapshots remove a lot of pressure. When everything goes wrong, the VM snapshot can be brought back in a few seconds and one can start over, no harm done.

Virtual Machine 2

After the OS upgrade to 22.04 on this machine, it took around 3 minutes after the first reboot until the VM was available again. A bit long. So I had a look at the boot process and noticed that a task that was unnecessarily waiting for the already available network blocked the startup for two minutes. Very strange, why didn’t this happen on the first machine!? After searching the web for a while, I found this post that describes how to find the responsible system service for this, which turned out to be iscsi. As I don’t need iscsi anyway, I disabled service startup. After that, the VM booted in just a few seconds. Nice! I then applied the knowledge gained from the update on the first VM, disabled the PHP 7.4 module and activated Apache’s PHP 8.1 module. I then started Apache again and was expecting to see it abort with the same error messages as in the first VM. To my surprise this was not the case and Nextcloud worked without a hitch. How strange!?

Virtual Machine 3

On this machine, I had the same issue as on the first VM, Apache would quit when rebooting after the OS upgrade with a strange error message on startup that something in the apache.conf file was wrong. I then noticed that the thing I didn’t do here was to replace the PHP7.4 module with the PHP 8.1 module in the Apache configuration straight away (sudo a2dismod php7.4 followed by a sudo a2enmod php8.1) before trying to start Apache. So could this be the reason for the strange error message? And indeed it was! Once I activated the PHP 8.1 module, the strange startup error disappeared.

However, again to my surprise, Nextcloud didn’t load, I just got an empty screen. In the Nextcloud log, Nextcloud actually complained about an unimplemented function. After a quick search on the net, it turned out that this function is part of the php8.1-xml package, which I then installed by hand via apt. And voila, Nextcloud started working again. Which begs the question why this only happened after upgrading the OS of the third instance and not on the other two!?

Virtual Machine 4

This time around, I immediately replaced PHP 7.4 for 8.1 in the Apache module list after rebooting once the OS upgrade was done and installed the php8.1-xml package, which was missing here as well. A minute later and Nextcloud was up and running again. It just took 4 upgrade iterations to make the process run smoothly.


All is well now, and my Nextcloud instances are all on Ubuntu 22.04 and PHP 8.1. The main takeaways: Strange error messages that don’t point to the real reason are a pain and cloned VM Nextcloud instances seem to drift apart over time and create individual challenges when doing an OS upgrade. The hero in the story: VM snapshots, as they offer the ultimate fail safe and peace of mind!