How to install multiple PHP versions on linux

You can install all versions of php either from source or install the default version using yum installer.
My server has php5.3 already installed and I am going to install PHP5.6 from source.

Prerequisites

Install suphp and configure
mkdir -p /usr/local/php56
mkdir -p /etc/php56
mkdir -p /etc/php56/php.d

Download php5.6

wget http://de1.php.net/distributions/php-5.6.19.tar.gz

Compile php

./configure –prefix=/usr/local/php56 –with-config-file-path=/etc/php56 –with-config-file-scan-dir=/etc/php56/php.d –with-libdir=lib64 –with-mysql –with-mysqli  –enable-mbstring –disable-debug –disable-rpath –with-bz2 –with-curl –with-gettext –with-iconv –with-openssl –with-gd –with-mcrypt –with-pcre-regex –with-zlib –enable-soap –enable-sockets –enable-zip –enable-bcmath –enable-calendar –enable-exif –enable-gd-native-ttf –with-freetype-dir –with-jpeg-dir –with-png-dir

Notes: You may see errors that few packages were not installed. In most case you will need to install devel packages.

eg: yum install libjpeg-turbo-devel
yum install libxml2-dev
yum install bzip2-devel
You need to compile it again after installing the packages.
Copy php.ini file

cp php.ini-production /usr/local/php56/php.ini

In order to enable multiple PHP versions, we need to install suphp on the server. I assume the server has suphp configured already. Make the following changes
edit the file /etc/suphp.conf and add the line

application/x-httpd-php56=”php:/usr/local/php56/bin/php-cgi”

Edit the file /etc/httpd/conf.d/php.conf and add following lines

suPHP_AddHandler application/x-httpd-php56
Enable PHP5.6 for a folder/site

create an .htaccess file and add following line

AddHandler application/x-httpd-php56 .php

Hosting Ahead

Recent Posts

Run composer with different PHP version

If multiple PHP versions are installed on your server you need to tell the composer…

2 years ago

How to Install WordPress using WordPress Toolkit in cPanel

Wordpress toolkit allows the installation, configuration, and management of Wordpress. The first step is to…

3 years ago

Configure OpenVPN Client Devices for Andriod

These instructions cover installing and configuring the OpenVPN Connect app  Client-Side Configurations: Android There are…

3 years ago

The certificate chain was issued by an authority that is not trusted | SQL Server

This error may appear when you try to connect to Microsft SQL server or you…

4 years ago

Free website hosting support in this COVID pandemic

Hello everyone, The COVID-19 should have affected almost everyone in a way or another. When…

4 years ago

Amazon workspaces to build a secure work from home cloud infrastructure

Based on the current Covid19 scenario, several companies asked employees to work from home. Google…

4 years ago