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.