We had few requests to support different PHP versions per directory . While this is not available using PHP Selector UI , it is fairly simple to do manually .

1. Configure handlers for different versions and point them to already provided php-cgi binaries, they all are visible from CageFS inside. Add the following section to [handlers] section in /opt/suphp/etc/suphp.conf :

           application/x-httpd-php52="php:/opt/alt/php52/usr/bin/php-cgi"
           application/x-httpd-php53="php:/opt/alt/php53/usr/bin/php-cgi"
           application/x-httpd-php54="php:/opt/alt/php54/usr/bin/php-cgi"
           application/x-httpd-php55="php:/opt/alt/php55/usr/bin/php-cgi"
           application/x-httpd-php56="php:/opt/alt/php56/usr/bin/php-cgi"

2. Add suPHP handlers for each version, this should be done before other configs. On cPanel server, edit /usr/local/apache/conf/includes/pre_virtualhost_global.conf and add the 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
             </Directory>
            </IfModule>

3. Restart Apache.

That’s it, now Apache understands what binary should be used for different mime types. To use desired version in a particular directory, just add a line to .htaccess in that directory (or create .htaccess file with that line, if it is not there).

For example, for php5.4, add the following line:

             AddHandler application/x-httpd-php54.php.php5

Subdirectories will use the same PHP version as the parent, unless you override it with another .htaccess entry in that subdirectory.



Was this answer helpful? 0 Users Found This Useful (1 Votes)