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. The latter mode enables you 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 https://rpms.remirepo.net/enterprise/remi-release-$(rpm -E %$ID).rpm && dnf clean all
Install additional PHP packages
dnf install php81-php-{cli,fpm,pdo,gd,mbstring,mysqlnd,opcache,curl,xml,zip}
Note: php81 should be replaced with the PHP version you want to install in the command above, i.e. php74. Depending on your OS version, different versions of PHP may be available, which you'll have to check the Remi repository website or search for available packages using dnf search php command.
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 https://packages.sury.org/php/apt.gpg && sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/sury-debian-php-$(lsb_release -sc).list' && 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 a specific PHP version you want 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 SURY website or search the repos using, e.g. apt search php7.4
.
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, e.g. apt search php7.4
.
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.
