You can configure the server to use different PHP versions on your subdomains and directories by adding the SetHandler code in the .htaccess file of the folder to override the default PHP version.
For example, your website www.yourdomainname.com requires PHP version 5.6 and the application on your website which is stored at www.yourdomainname.com/application requires PHP version 7.0 to execute, follow these steps to configure the PHP versions for your subdomains or directories.
Step 1: Log in to your control panel. Learn how.
Step 2: Navigate to the Order View
Search the domain name for which you have purchased the hosting order and select the domain to view the order information.
Step 3: Access the cPanel
Learn More
In your cPanel click File Manager.
Step 4: Configure PHP Version
- Navigate to the directory for which you want to use a different PHP version.
- Open the .htaccess file. If you don't see the file try enabling hidden files from settings or else create a .htaccess file.
- Add the code to the file.
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-lsphp56 </FilesMatch>
Tip
Depending on the version you want to use, modify the SetHandler line in the code.
- PHP Version 5.1 - application/x-lsphp51
- PHP Version 5.2 - application/x-lsphp52
- PHP Version 5.3 - application/x-lsphp53
- PHP Version 5.4 - application/x-lsphp54
- PHP Version 5.5 - application/x-lsphp55
- PHP Version 5.6 - application/x-lsphp56
- PHP Version 7.0 - application/x-lsphp70
- PHP Version 7.1 - application/x-lsphp71
Example: If you want the folder to use PHP version 7.1 add the following code to /home/user/public_html/subfolder/.htaccess
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp71
</FilesMatch>