How To Use Multiple PHP Versions on cPanel server

12 Sep

cPanel doesn’t support php 5.2. cPanel only comes with php 5.3, 5.4 and 5.5 but we can only use single version php on our default install. Few people still use older version php. So If we update our server then apps can break. Also some apps need higher version php. So we need multiple version php on our server. We can overcome this issue using CloudLinux, because cloudlinux released php selector for cloudlinux based cPanel server. To use cloudlinux php selector, you need to purchase CloudLinux License.

 

To install PHP Selector presumes that you already have CageFS & LVE Manager installed.

 

Installation of different versions of PHP & modules:

$ yum groupinstall alt-php

 

Update CageFS & LVE Manager with support for PHP Alternatives

$ yum update cagefs lvemanager

 

cPanel/WHM: Make sure ‘Select PHP version’ is enabled in Feature Manager

 

IMPORTANT: Please, do not use settings like SuPHP_ConfigPath, PHPRC, PHP_INI_SCAN_DIR. Do not redefine path to php.ini and ini-files for php modules. Doing that can break PHP Selector functionality.

 

For example, alternative php5.2 versions should load /opt/alt/php52/etc/php.ini file and scan /opt/alt/php52/etc/php.d directory for modules:

Configuration File (php.ini) Path         /opt/alt/php52/etc
Loaded Configuration File                 /opt/alt/php52/etc/php.ini
Scan this dir for additional .ini files   /opt/alt/php52/etc/php.d
additional .ini files parsed              /opt/alt/php52/etc/php.d/alt_php.ini

Those are default locations for alt-php.

 

If you need custom PHP settings per user, please change them via “Edit PHP settings” feature of PHP Selector.

 

If you don’t want to pay for CloudLinux, okay no problem. We can use ntPHPselector. ntPHPselector is absolutely free for use.

ntPHPselector plugin allows user to select preferred PHP version per directory on the same domain.

Note : ntPHPselector plugin require SuPHP on the system; it will not work with any other PHP handlers for now.

 

Install ntPHPselector

We need to run following command to install ntPHPselector

cd /usr/local/src
wget -N http://nixtree.com/download/free/ntphpselector_manage.sh
sh ntphpselector_manage.sh install

 

Now need to recompile php in ntPHPselector.

sh ntphpselector_manage.sh recompile

— option

  • 2 for 5.2
  • 3 for 5.3
  • 4 for 5.4
  • 5 for 5.5

eg: recompile php5.2
sh ntphpselector_manage.sh recompile 2

 

Now we can use multiple versions of PHP on our cPanel server.

14021 Total Views 18 Views Today

4 thoughts on “How To Use Multiple PHP Versions on cPanel server

  1. In the past cPanel supported running both PHP4 and PHP5, and users could select which one they wanted via mime type settings and .htaccess.However, now there is a migration issue with PHP5.2 and now PHP5.4. I’ve been waiting for something similar in cPanel to run both at the same time — so users who use legacy can use PHP5.2 and those who want the newest can run PHP 5.4… Is there a way compatible with cPanel to run both on Apache?

Leave a Reply

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