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