Introduction
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. Latter mode enables to set different PHP versions on per-directory basis.
Installing on Alma, Rocky, CentOS Stream, Fedora Linux
Install Remi repository and clear cache
. /etc/os-release && dnf -y install //rpms.remirepo.net/enterprise/remi-release-$(rpm -E %$ID).rpm && dnf clean allInstall additional PHP packages
dnf install php*-php-{cli,fpm,pdo,gd,mbstring,mysqlnd,opcache,xml,zip}Note: php* should be replaced with a specific PHP version, i.e. php74, unless you really need to install all available additional PHP versions.
Installing on Debian
Enable sury/php repository
apt-get -y install apt-transport-https lsb-release ca-certificates curl && curl -sSL -o /etc/apt/trusted.gpg.d/php.gpg //packages.sury.org/php/apt.gpg && sh -c 'echo "deb //packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/sury-debian-php-$(lsb_release -sc).list' && apt-get updateInstall additional PHP packages
apt-get install php*-{cgi,cli,fpm,pdo,gd,mbstring,mysqlnd,opcache,xml,zip}Note: php* should be replaced with a specific PHP version, i.e. php7.4, unless you really need to install all available additional PHP versions.
Installing on Ubuntu
Enable ondrej/php repository
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && apt-get updateInstall additional PHP packages
apt-get install php*-{cgi,cli,fpm,pdo,gd,mbstring,mysqlnd,opcache,xml,zip}Note: php* should be replaced with a specific PHP version, i.e. php7.4, unless you really need to install all available additional PHP versions.
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:
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.