PureDevOps Community

Ubuntu: How to install multiple php version in virtualmin

I have already runnin php version 7 in my virtual server , for one of my website i want to install php version 8 ?

If you have multiple PHP versions installed, Virtualmin allows you to choose execution mode and PHP version used for a given domain. Available execution modes are FPM (recommended) and CGI/FCGId. The latter mode enables you to set different PHP versions on per-directory basis.

Installing on Ubuntu

Enable ondrej/php repository

LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && apt-get update

Install additional PHP packages

apt-get install php8.1-{cgi,cli,fpm,pdo,gd,mbstring,mysqlnd,opcache,curl,xml,zip}

Note: php8.1 should be replaced with the PHP version you wish to install, i.e. php7.4.The available PHP versions may depend on your distro and version, which you can check available versions on the Ondrej PPA website or search the repos using .

Configuring the second PHP Version in Virtualmin

Once you have completed the installation of a second PHP version on your server, 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 execution modes are available : fpm The following PHP-FPM versions are available : 8.0.13 (php-fpm) 7.4.30 (php74-php-fpm) 8.2.0 (php82-php-fpm)

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 page.

Configuring Individual Virtual Servers

You can configure the PHP version being used for a specific Virtual Server by selecting Server Configuration → PHP Options.

Ref: Multiple PHP Versions – Virtualmin