Here at WebHostFace we are always aiming at providing custom solutions for our clients. In order to provide a more versatile hosting environment, we have added the option to run multiple PHP versions on your shared account simultaneously. On shared hosting you can select any of the following versions: 4.4, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 7.0, and 7.1*. The native PHP version for all shared hosting accounts is 5.6.
To do that you will need access to your shared account either via cPanel or FTP and be able to edit the .htaccess file.
Let’s start first with choosing the default version for your account. You can do that via cPanel > Software > Select PHP Version.
Just choose the desired version and press Set as current.
That configuration now becomes the default for your whole account.
However, you can change that for any directory on your cPanel, thus configuring different websites, subdirectories, etc to use different PHP versions. To do so you need to insert a rule into your .htaccess file. This file is hidden by default so to be able to see it, you should tick the Show Hidden Files option inside your File Manager > Settings.
Then navigate to the desired folder and select the .htaccess file. If there isn’t one, you can go ahead and create a new one. Once it is selected, right click on it and select Code Edit.
Now paste the following lines at the top of your file as follows:
#In order to change the version to 5.5 - <FilesMatch ".(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-httpd-alt-php55___lsphp </FilesMatch>
#In order to change the version to 7.0 - <FilesMatch ".(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-httpd-alt-php70___lsphp </FilesMatch>
The lsphpXX on the second line determines the PHP version.
Click Save and close the Code Editor.
It is a good idea to create a phpinfo file to test the changes right away.