Multiple PHP version on Virtualmin in Ubuntu 16.04

Reading Time: 3 minutes

Today, let us try to install multiple PHP version based on your needs. In my case, I will install 5.6, 7.0, 7.2, 7.3 Virtualmin in Ubuntu 16.04. By default, Virtualmin installs PHP 7.0.33 on my Droplet, see the screenshot below:

image-41-1024x241 Multiple PHP version on Virtualmin in Ubuntu 16.04
The following PHP versions are available : 7.0.33 (/usr/bin/php-cgi7.0)

Let us get started!

Install the PPA.

add-apt-repository ppa:ondrej/php && apt-get update


[email protected]:~# add-apt-repository ppa:ondrej/php && apt-get update

Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP ( for Supported Ubuntu Releases ( are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.

Debian oldstable and stable packages are provided as well:

You can get more information about the packages at

BUGS&FEATURES: This PPA now has a issue tracker:

1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline
   or ppa:ondrej/nginx

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly:

WARNING: add-apt-repository is broken with non-UTF-8 locales, see for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info:
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpucb8ek3e/secring.gpg' created
gpg: keyring `/tmp/tmpucb8ek3e/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server
gpg: /tmp/tmpucb8ek3e/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
Hit:1 xenial InRelease
Hit:2 xenial-updates InRelease                            
Hit:3 xenial-backports InRelease                          
Hit:4 main InRelease                        
Get:5 xenial InRelease [23.9 kB]                      
Get:6 xenial-security InRelease [109 kB]                       
Hit:7 xenial InRelease                                          
Hit:8 virtualmin-xenial InRelease                    
Hit:9 virtualmin-universal InRelease                 
Get:10 xenial/main amd64 Packages [52.3 kB]           
Get:11 xenial/main Translation-en [28.2 kB]
Fetched 213 kB in 1s (112 kB/s)                     
Reading package lists... Done

If successfully, let us start with PHP 7.3 installation.

PHP installation.

apt-get install php7.3 php7.3-mysql php7.3-cgi php7.3-cli -y

Once you have completed the installation, you can verify that Virtualmin sees it by logging into Virtualmin, and clicking System Settings -> Re-Check Config. You should see something like this:

The following PHP versions are available : 7.0.33 (/usr/bin/php-cgi7.0), 7.3.6 (/usr/bin/php-cgi7.3)

You can configure which one is the default PHP version used on new Virtual Servers. The default is to use the newest available. You can change that default in System Settings -> Server Templates -> Default -> PHP Options, and on that screen you can set the default PHP version to use in the field Default PHP version.

Finally, if you wish to install your desired PHP version, change the 7.3 to your desired version instead. For example, if you wish to install the 5.6, run:

apt-get install php5.6 php5.6-mysql php5.6-cgi php5.6-cli -y

Configuring Individual Virtual Servers.

You can configure the PHP version being used for a specific Virtual Server by selecting Server Configuration -> PHP Versions.

For example:

image-42-1024x629 Multiple PHP version on Virtualmin in Ubuntu 16.04

At this point, you should be all set.

Multiple PHP Versions

Was this post helpful?

Leave a Reply