Change PHP version in folders


EXPERIENCING PROBLEMS WITH OUR SERVICES? RUN A DIAGNOSE FIRST TO SAVE YOURS AND OUR TIME

Added: 17.12.2018 15:38:29     Last updated: 17.01.2019 12:28:58

It is possible to set different PHP versions in folders by using a .htaccess file on our cPanel web hosting.
For most clients this is not needed, but those who have different scripts and many domains in the same hosting package where different PHP versions are required it is useful.
We recommend following the below mothod ff the above apply to you. Otherwise we recommend using the PHP Selector inside cPanel to have the same version for all folders.

.htaccess file
Find the desired folder trough File Manager / FTP / SSH. If there is no .htaccess file from before, it must be created. If it exists from before, you can change the existing one and enter the lines below to change the PHP version.
The example below changes the PHP version to PHP 7.0.

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


These PHP versions can be used:
application/x-httpd-alt-php44___lsphp - PHP 4.4
application/x-httpd-alt-php51___lsphp - PHP 5.1
application/x-httpd-alt-php52___lsphp - PHP 5.2
application/x-httpd-alt-php53___lsphp - PHP 5.3
application/x-httpd-alt-php54___lsphp - PHP 5.4
application/x-httpd-alt-php55___lsphp - PHP 5.5
application/x-httpd-alt-php56___lsphp - PHP 5.6
application/x-httpd-alt-php70___lsphp - PHP 7.0
application/x-httpd-alt-php71___lsphp - PHP 7.1
application/x-httpd-alt-php72___lsphp - PHP 7.2
application/x-httpd-alt-php73___lsphp - PHP 7.3

PHP extensions
To select and modify PHP extensions for the PHP versions used in other folders, it can be done inside the PHP Selector in cPanel as shown in the picture below.

  1. Select the PHP version you want to change the extension for.
  2. Select the desired PHP extension by ticking the one you want active.
  3. Press "Save". For example, check that the extensions are updated in a phpinfo file.
PHP Selector in cPanel


Live chat Live chat