Nextcloud Internal Server Error after upgrading Ubuntu from 22.04 to 24.04

After upgrading a server from Ubuntu 22.04 (Jammy Jellyfish) to 24.04 (Noble Numbat), a Nextcloud installation may break with the following error:

Internal Server Error 

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

The log file is stored in the data folder of the Nextcloud installation folder (/data/nextcloud.log).

Inspecting this file revealed the following error:

Exception”:”Doctrine\\DBAL\\Exception”,”Message”:”Failed to connect to the database: An exception occurred in the driver: could not find driver

The upgrade to Ubuntu 24.04 installs PHP version 8.3.  In some cases your system may have multiple versions of PHP installed which can cause issues during a Ubuntu release upgrade. You can check which version of PHP is set as the system default with the following command:

sudo update-alternatives --config php

Now check that Apache or Nginx are using the same version.

For Apache, you can check the version of PHP that is loaded with this command

ls /etc/apache2/mods-enabled/

To change the PHP version, use the following commands. Change X.X to appropriate value if it is not 8.3.

sudo a2dismod phpX.X
sudo a2enmod php8.3

Then restart Apache.

For Nextcloud and PHP-FPM, check the config files for enabled sites at this location

/etc/nginx/sites-enabled

For example, change any lines containing the old version /var/run/php/php8.x-fpm.sock to point to the new version/var/run/php/php8.3-fpm.sock. Then restart Nginx:

With PHP out of the way, check that you have the correct PHP modules installed.   Review your Nextcloud config file in the config folder of the Nextcloud installation folder (/config/config.php).

You’ll need the correct module based on dbtype variable, for example php-mysql.

sudo apt-get install php-mysql

If you have memory caching (optional), you will need to install the appropriate module based on the memcache.local variable for that as well, such as php-apcu.

sudo apt-get install php-apcu

Once complete, restart Apache or Nginx.

This entry was posted in Uncategorized. Bookmark the permalink.