This is an old revision of the document!

How to set different PHP versions per directories using PHP Selector for LSWS

Cloudlinux supports different PHP versions per directory. CloudLinux PHP Selector has already support mul-php version, why I need this.

While, please note this is not part of the standard CloudLinux PHP Selector setup. Each user can select different PHP version, but only one version can be selected for the whole user account. How about setting up different php version for different directories within one cage user? You will need setup outlined in this wiki, however you should use it very carefully.

If you are using control panel like cpanel, you may use this for EA3 but it is not campatible for EA4 since EA4 support multi versions of PHP by default already.

To use this cloudLinux feature, Minor manual changes are required to apache configuration as the following:

Add the following section to the end of /opt/suphp/etc/suphp.conf :


Add suphp handlers for each version, this should be done before other configs. On cPanel server, edit /usr/local/apache/conf/includes/pre_main_global.conf and add following section:

<IfModule mod_suphp.c> 
<Directory /> 
suPHP_AddHandler application/x-httpd-php52 
suPHP_AddHandler application/x-httpd-php53 
suPHP_AddHandler application/x-httpd-php54 
suPHP_AddHandler application/x-httpd-php55 
suPHP_AddHandler application/x-httpd-php56 

You can do the following to make LiteSpeed compatible with php selector per directory.

Step1: Force upgrade to the latest LSWS version

  /usr/local/lsws/admin/misc/ -f -v <version>

Step2: Create handlers for lsphp52/lsphp53/lsphp54/lsphp55/lsphp56/lsphp70 pointing to cloud linux PHP selector lsphp binary, such as /opt/alt/php5x/usr/bin/lsphp.

Step3: Create suffixed .php52 .php53 .php54 .php55 .php56 .php70 and associate them with above related external app handlers.

Step4: Restart LSWS.

  • Admin
  • Last modified: 2017/02/23 19:58
  • by Jackson Zhang