How to set a custom PHP version per directory
The PHP version is important not only for speed and performance. There are different applications, which sometimes may require specific PHP versions. With SiteCountry, all our cloud hosting clients can set specific PHP versions for different directories/domains/subdomains. For example, if you want to run PHP 8.0 on your account, but you have to set PHP 7.4 on any particular domain because of your specific application requirements, you can do that by setting custom rules for each of your folders. In this post, we will explain how to run multiple PHP versions on the very same account.
While this option is not directly accessible in our control panel, it is possible to have a different PHP version for an addon domain, subdomain, or on a per-folder basis by using handlers in your site’s .htaccess file.
You can easily change the PHP version on your account by using one of the following handlers, according to your desired PHP version.
How to set PHP 5.6 version for a specific domain.
Let’s have a practical example of how to set the PHP 5.6 version for any one of the domains.
.htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from the default PHP version with the following handler:
As a result, an addon domain, for instance, will use the PHP 5.6 version which you’ve set for it, and not the global one set for the account in the Control Panel > PHP Selector.
How to set PHP 7 version for a specific domain.
Let’s have a practical example of how to set the PHP 7 version for any one of the domains.
.htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from the default PHP version with the following handler:
#SiteCountry Custom PHP Version 7
<FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp70
</FilesMatch>
#Custom PHP Version Code Ends