After upgrading a server from Ubuntu 22.04 (Jammy Jellyfish) to 24.04 (Noble Numbat), the Apache installation no longer functioned properly. WordPress was also installed and would give the error:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Please check that the mysqli PHP extension is installed and enabled.
Also phpMyAdmin would give the following error
The mysqli extension is missing. Please check your PHP configuration.
This was confusing because the php-mysql plugin was already installed on the system. Many guides walk you through manually uncommenting the lines for the mysqli and pdo_mysql extensions in php.ini. Doing that had no effect.
Some guides will also have you create a PHP Info page to confirm whether the MySQL extension is enabled. In the server’s webroot location, create a new php file with the following code:
<?php phpinfo(); ?>
Save the file , then browse to that webpage using a web browser. This offered the first clue. At the top it the titled listed PHP Version 8.2 but Ubuntu 24.04 is by default configured for PHP 8.3.
Digging into this further, the server had multiple versions of php installed. You can check this by running the following command:
sudo update-alternatives --config php
In this case it was confirmed that 8.3 was set as the system default, but the title of the PHP Info webpage confirmed Apache was configured for the older 8.2 version.
You can check which version of PHP is configured for Apache by using the following command to list all of the modules currently loaded:
ls /etc/apache2/mods-enabled/
It was found that the server had a file named php8.2.load in the list. The following commands will change the version of PHP module that Apache used from 8.2 to 8.3:
sudo a2dismod php8.2
sudo a2enmod php8.3
sudo service apache2 restart
After that was complete, both WordPress and phpMyAdmin started working again.
If you are using Nginx with PHP-FPM, then you will need to edit the config file for each enabled site to point to the newer version. The site configuration files are stored at:
/etc/nginx/sites-enabled
For example, change any lines containing the old version /var/run/php/php8.2-fpm.sock to point to the new version/var/run/php/php8.3-fpm.sock. Then restart Nginx:
sudo service nginx restart