Knowledge Base


Setting up different PHP Versions in different folders / domains / subdomains for my cPanel account

This is a guide to show you have to set use a different PHP Version for different subdomains/folders/domains. This allows you to use different PHP Versions in different domains.


STEP 1 : Login to cPanel ( Guide here )


STEP 2 − Navigate to Domains -> Domains. Click on Domains


STEP 3 − Navigate to the Domain that you want to change the PHP Version. Click on Document Root for that domain ( Eg. For blog.hostkoala.com , click on /blog.hostkoala.com which is the document root for that subdomain ). THis brings you to the file manager of that subdomain.


STEP 3 − On the top right of the file manager, to click on Settings


STEP 4 − Tick the Show Hidden Files ( dotfiles ) section, and click Save


STEP 5 -  Find the .htaccess file , and right click on it, and click Edit


STEP 6 - Add the following lines at the end of the .htaccess file, and click Save Changes on the top right.

<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".

And you're done :)

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

0 0