Recently, we have had clients ask how to run different PHP versions in the same cPanel account. Unfortunately, this is not available with the PHP Selector at the time of this writing, but there is still a way to achieve this.
The first requirement is that PHP needs to be running in suPHP mode. All shared, cloud and managed dedicated servers from GlowHost run in suPHP mode. Below are the steps to achieve the result you are looking for:
Steps 1 through 3 are not required on shared GlowHost servers as we have already done this part for you. If you have a shared, reseller, or semi-dedicated account, please skip to step 4.
1. Configure handlers for the different PHP versions and point them to the existing php-cgi binaries. These are all visible from CageFS. The code should look something like this in the [handlers] section in /opt/suphp/etc/suphp.conf:
2. Add suPHP handlers for each version you need Please note that this should be done before other configs. On the cPanel server, add the following section /usr/local/apache/conf/includes/pre_virtualhost_global.conf:
3. Restart apache. Now apache will understand what binary should be used each mime type.
For example for php 5.4, add the following line in .htaccess will be:
AddHandler application/x-httpd-php54 .php .php5
-Subdirectories will use the same PHP version as the parent directory unless you override it with another .htaccess entry in that subdirectory.
-PHP extension selection will match the extensions selected by end user for that PHP version in PHP Selector.
-Some modules may not be enabled, you may need to add them in your php.ini. For example, if you see something like MySQL module is not enabled, you need to add into your php.ini the following:
-This is not an ‘officially’ supported way to run multiple PHP versions per account, but it is a safe hack that will work for anyone using suPHP.