Tech YouTubers

Let's learn the Technology to Change the World!

Internet

How to Install and use Multiple PHP Versions on Virtualmin

How to Install and Use Multiple PHP on Virtualmin. Unlock the flexibility of Virtualmin by installing and utilizing multiple PHP versions on your server. In this detailed guide, we’ll walk you through the process of setting up and managing multiple PHP versions to cater to diverse web applications. From installation to configuration and virtual server settings, learn the essential steps to ensure a seamless coexistence of different PHP versions. Whether you’re a web developer or a system administrator, this tutorial empowers you to harness the full potential of Virtualmin for your PHP-based projects.

Installing PHP 7.3 on CentOS 6 and 7

Install the SCL Repo:

yum -y install centos-release-scl

Install the PHP packages:

yum -y install rh-php73-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}

Installing PHP 7.4 and/or 8.0 on CentOS 7

Install Remi Release repo and clear cache:

yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm && yum clean all

Install PHP packages version 7.4 and/or 8.0:

yum -y install php74-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}
yum -y install php80-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}

Installing PHP 7.3, 7.4 and/or 8.0 on CentOS 8

Install Remi Release repo and clear cache:

dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm && dnf clean all

Install PHP packages version 7.3 and/or 7.4:

dnf -y install php73-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache} 
dnf -y install php74-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}
dnf -y install php80-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}

Installing PHP 5.6 and/or 7.4 and/or 8.0 on Debian 9/10

Enable the DEB.SURY.ORG 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/php.list'

Update all repositories:

apt update

Install PHP packages version 5.6 and/or 7.4 and/or 8.0:

apt-get install php5.6-{cli,pdo,fpm,zip,gd,xml,mysql,cgi} 
apt-get install php7.4-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
apt-get install php8.0-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}

Installing PHP version 5.6 and/or 7.3 and/or 8.0 on Ubuntu 16.04, 18.04 and 20.04

Install the PPA:

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

Install the PHP packages:

apt-get install php5.6-{cli,pdo,fpm,zip,gd,xml,mysql,cgi} 
apt-get install php7.3-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
apt-get install php8.0-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}

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 versions are available : 5.3.3 (/usr/bin/php-cgi), 5.6.25 (/opt/rh/rh-php56/root/usr/bin/php-cgi), 7.0.10 (/opt/rh/rh-php70/root/usr/bin/php-cgi)

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.

Thanks for Reading!

Leave a Reply

Tech YouTubers