Install multiple version php’s in litespeed server

The default installation of LiteSpeed provide PHP4 and PHP5. With cPanel or other hosting control panel, admin can provide multiple PHP versions (e.g. PHP 5.2.x or PHP 5.3.x for PHP5). To provide multiple versions at the same time, a custom setup is needed. This document details the steps to create custom PHP script handler in the litespped server (cPanel, DirectAdmin) to provide multiple PHP versions.

Here I am compiling php5.3.10 through easyapache and php5.2 via manually.

1) Compile the default php-5.3.10 version through easyapache(cpanel) or custom build (directadmin)

2) Follow the below steps to compile php5.2.17

wget http://us.php.net/get/php-5.2.17.tar.gz/from/this/mirror

tar -zxvf php-5.2.17.tar.gz

cd php-5.2.17

 ./configure --enable-bcmath --enable-calendar --enable-exif --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-magic-quotes --enable-mbstring --enable-pdo=shared --enable-soap --enable-sockets --enable-ucd-snmp-hack --enable-zip --prefix=/usr/local/php52 --with-curl=/opt/curlssl/ --with-curlwrappers --with-freetype-dir=/usr --with-gd --with-imap=/opt/php_with_imap_client/ --with-imap-ssl=/usr --with-jpeg-dir=/usr --with-kerberos --with-libdir=lib64 --with-libexpat-dir=/usr --with-libxml-dir=/opt/xml2 --with-libxml-dir=/opt/xml2/ --with-mcrypt=/opt/libmcrypt/ --with-mhash=/opt/mhash/ --with-mysql=/usr --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mysqli=/usr/bin/mysql_config --with-openssl=/usr --with-openssl-dir=/usr --with-pcre-regex=/opt/pcre --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-pic --with-png-dir=/usr --with-snmp --with-sqlite=shared --with-tidy=/opt/tidy/ --with-ttf --with-xmlrpc --with-xpm-dir=/usr --with-xsl=/opt/xslt/ --with-zlib --with-zlib-dir=/usr --with-litespeed

make && make install

3)   Each PHP version binary is setup as LSAPI type External App (with its unique name) at LSWS server level (LSWS Admin Console –> Configuration –> Server –> External App –> Add)

Name: lsphp52 
Address: uds://tmp/lshttpd/lsphp2.sock 
Command: /usr/local/php52/bin/lsphp 
Auto Start: Yes 
Memory Soft Limit(bytes): 200M 
Memory Hard Limit(bytes): 300M 
Process Soft Limit: 200 
Process Hard Limit: 200

4) Create Script Handler for each Ext App at LSWS server level which in turn assign PHP version with MIME type in LSWS (LSWS Admin Console –> Configuration –> Server –> Script Handler –>Add)

suffix : php52
Handler Type : Litespeed API
Handler Name : lsphp52

  This in turn creates MIME type for multiple PHPs as follows:

       application/x-httpd-php52

and restart litespeed server

5)  . Add below MIME type in  httpd.conf or  .htaccess.   

AddHandler application/x-httpd-php52 .php
 OR
AddType application/x-httpd-php52 php

Thats all 🙂

 

Install multiple version php’s in litespeed server
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fork me on GitHub