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.

cPanel:

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.

 

  • php, htaccess, php version
  • 0 utilizatori au considerat informația utilă
Răspunsul a fost util?

Articole similare

How do I create a PHP info page?

You can display the servers PHP configuration and what modules are currently loaded using a PHP...

How to choose PHP version on Linux hosting?

To choose your PHP version:In cPanel go to "Software/Services"Click "Select PHP Version"Click the...