CloudLinux - CloudLinux Blog - Different PHP versions per directories using mod_lsapi

Different PHP versions per directories using mod_lsapi

Different PHP versions per directories using mod_lsapi

In regards to our previous post about different PHP versions when using suphp, here is an easy instruction of how to setup different PHP versions per directories when using mod_lsapi.

Assuming that you already have CageFS, PHP Selector and mod_lsapi installed, perform the following steps:

1. Setup mod_lsapi (no matter globally or per domain).

2. Create /etc/container/php.handler file with handlers for different versions:

application/x-lsphp52 /opt/alt/php52/usr/bin/lsphp
application/x-lsphp53 /opt/alt/php53/usr/bin/lsphp
application/x-lsphp54 /opt/alt/php54/usr/bin/lsphp
application/x-lsphp55 /opt/alt/php55/usr/bin/lsphp

3. Restart Apache.

4. Create .htaccess file in desired directory where you want to have a different from default PHP version with right handler:

AddType application/x-lsphp53 .php5 .php4 .php .php3 .php2 .phtml

As the result, subdirectories will use the same PHP version as parent unless you overwrite it with another .htaccess entry in that subdirectory.

To match PHP extensions selection with extensions selected by end user for that PHP version in PHP Selector you have to follow
This way the main website can use native PHP handler (suphp/fcgi) while subdirectory is using lsapi with necessary PHP version.
CloudLinux 7.1 Released
New beta kernel for CloudLinux 7

By accepting you will be accessing a service provided by a third-party external to

EU e-Privacy Directive

We use cookies to ensure you get the best experience using our website and services. Read more about it in our Privacy Policy. Please agree to the use of cookies to proceed. Alternatively, you may disable cookies in your browser at any time.

You have declined cookies. This decision can be reversed.

You have allowed cookies to be placed on your computer. This decision can be reversed.