Virtualmin on Ubuntu – add support for newer php versions

The latest versions of php come with big performance improvements. However, a downside is that older code might have unexpected behaviour – as the improvement list is quite long.

Command line

To get things going, you need to log into your server and execute the following commands with elevated privileges:

# Add the PPA
sudo add-apt-repository ppa:ondrej/php && sudo apt-get update

# Install the php 7.3 packages
sudo apt-get install php7.3 php7.3-mysql php7.3-cgi php7.3-cli

During the install you might be prompted to uninstall packages that are not necessary – you should be very careful about what you choose to remove. Also, you should note that adding the PPA might lead to new update notices.

Virtualmin

Once the install is done, you should login to your Webmin/Virtualmin interface and on the Virtualmin tab, go to System settings > Re-check config.

For newly created hosts, by default the latest version is used.

For the existing hosts, it is recommended to proceed with manually updating each of the projects to ensure there won’t be any issues.

More information:

Complications

At times, you might encounter some difficulties, due to the fact that Virtualmin is not very-very good at automatically updating configuration files. Thus, after the above or maybe updating your php versions – as it was in my case – you might find out that php files are no longer executed on your server.

One reason might be that while re-rechecking and updating the configuration files, Virtualmin adds php_admin_value engine Off in the config files. To fix this, you should go in /etc/apache2/sites-available and edit it out of all the files there.

Also, you should edit /etc/apache2/mods-available/php7.x.conf and comment out SetHandler application/x-httpd-php. Depending, on your php version, the name of the file might vary.

More information: