How to add multiple PHP versions to Virtualmin

CentOS has a software collections repo that allows you to install multiple PHP versions. If you just prefer to upgrade the PHP on your box, see this article instead: https://www.virtualmin.com/node/48280. Please note this link provided to install to upgrade PHP version of your box might clash with the side-by-side method described below.

To install multiple PHP versions on a Virtualmin control panel:

yum install centos-release-scl
yum install rh-php72 rh-php72-php-mysqlnd

Substitute the “72” with whichever version of PHP that you want to install.

Now login to Virtualmin and do:

System Settings -> Re-Check Configuration

You should get a notice that a new version of PHP was installed and configured, for example:

The following PHP versions are available : 5.4.16 (/bin/php-cgi), 7.0.27 (/opt/rh/rh-php70/root/usr/bin/php-cgi), 7.1.8 (/opt/rh/rh-php71/root/usr/bin/php-cgi), 5.4 (mod_php)

Note:

Just because you installed PHP from the command line doesn’t mean every single package you need to run your applications will be available.

The “rh-” format can be used to install any missing PHP package.

For example, let’s say you want to install GD Graphics Library. for PHP 7.2:

yum install  rh-php72-php-gd

or 7.1:

yum install rh-php70-php-gd

An example for PHP 7.1:

yum install rh-php71-php-bcmath

Reference:
https://www.virtualmin.com/documentation/web/multiplephp

Share this article

Scroll to Top