Knowledge Base How do I set the PHP version for a directory?

How do I set the PHP version for a directory?

We understand that sometimes you may install multiple apps that will require different PHP versions, however, the PHP Selector will only allow you to choose one PHP version for your entire account.

Luckily, there is a workaround for the issue.

Simply add the following code to your .htaccess file for the directory you need to have the different PHP version on:

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php71___lsphp
</FilesMatch>

The above code would enable PHP version 7.1 for the directory. You can change "php71" in the above code to the PHP version you need.

For example, if you need PHP version 7.3, you would use "php73".

*Please note, only the available PHP versions found in the PHP Selector in cPanel are supported versions.

You can also enable/disable PHP modules for the version you choose from the PHP Selector. Just choose the PHP version in the PHP Selector and click the modules to enable. 

Please rate this article to help us improve our Knowledge Base.

7 0