Skip to main content

Setting up multiple PHP versions in Webmin/Virtualmin

This guide explains how to configure Multiple PHP Versions in Webmin/Virtualmin

Updated over 2 weeks ago

Webmin control panel allows you to have several PHP versions in the same server. There is a possibility to choose different PHP versions for separate Virtual Servers.

Please note: by default, PHP versions such as 7.4, 8.0, and 8.4 are already installed.

0. Preliminary requirements

  • Webmin 2.3 (AlmaLinux 9, PHP 8.4, MariaDB 10.11) is installed on our server;

  • Fully updates server software (dnf update).

1. Log into your server

Log in to your server via SSH with root user. How to log into Linux based server see here.

2. Setting Up the Remi Repository

The Remi repository provides access to multiple PHP versions. To enable it:

. /etc/os-release && repo_dir=$([ "$ID" = "fedora" ] && echo "fedora" || echo "enterprise") && dnf -y install "https://rpms.remirepo.net/$repo_dir/remi-release-$(rpm -E %$ID).rpm" && dnf clean all

3. Installing Additional PHP Versions

Install your preferred PHP version by replacing php82 with the version number you need, such as php83 or any other:

dnf install php82-php-{cli,fpm,pdo,gd,mbstring,mysqlnd,opcache,curl,xml,zip}

To explore other available versions or extensions:

dnf search php

This will list all versions and compatible modules in the Remi repository.

4. Adding Extensions for All Installed PHP Versions

If you have multiple PHP versions installed, you can bulk-install specific extensions for all of them at once. For example, to add curl and intl:

for php in $(scl list-collections 2>/dev/null | grep 'php' | sed 's/$/-php/'); do 
for ext in curl intl; do
sudo dnf -y install "${php}-${ext}"
done
done

Modify curl intl with the extension names you need, separated by spaces.

5. Configuring the Default PHP Version in Virtualmin

After installation, integrate PHP with Virtualmin:

5.1. Recheck system configuration:

In Virtualmin, go to System Settings β†’ Re-Check Configuration.
This will confirm the availability of installed PHP versions.

5.2. Set the default PHP version:

  • For all new virtual servers: System Settings β†’ Server Templates β†’ PHP Options.

  • For a specific virtual server: Web Configuration β†’ PHP Options.

This ensures the right PHP version is used for your web applications.

Did this answer your question?