How do I use a different PHP version in a subdomain or folder?
There are times you may find the need to use a specific PHP version for a subdomain application that is different from your main account PHP version.
The following will show you how to use a different PHP version in specific folder and/or subdomain than that of the main account PHP version.
In the folder you want the PHP version changed or different, you need to edit the .htaccess file add the following code:
cPanel
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php80___lsphp
</FilesMatch>
DirectAdmin
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-lsphp80 </FilesMatch>
In the above examples, simply replace the "php80" portion with the PHP version of your choosing.
For example, if you wanted to use PHP 7.4 you would use "php74".
To see the available PHP versions, you can go to "Select PHP Version" in your cPanel or DirectAdmin control panel.
Note: The .htaccess file is a system file and is hidden by default in cPanel, so you will need to choose to "Show Hidden Files" in your File Manager settings to see it.
If your folder does not contain a .htaccess file, you can simply create one using the File Manager.