How to change the PHP version of a folder or subdomain?
If you want to update the PHP version applicable to your account, you can do so directly from cPanel.
You can also modify the PHP version for only one of your domains, subdomains or folders. Simply add a line of code to the .htaccess.
Log in to your cPanel account (via your customer account or https://www.bmoname.com:2083).
In the Files section of your control panel, click your File Manager.
Navigate to the folder or subdomain you want to change the PHP version of. Then find the . htaccess associated with it, or create a new one if necessary.
Modify your .htaccess file to include this code:
Note that the second line of the code defines the version of PHP that will be used. In the previous example, the code defined version 8.2 as the one to use.
If you want to use another version, you must adjust the code according to your choice. Here are the codes for the different versions of PHP:
Save the changes to your .htaccess file so that the change takes effect.
You can also modify the PHP version for only one of your domains, subdomains or folders. Simply add a line of code to the .htaccess.
Steps to change the PHP version of a folder or subdomain
Log in to your cPanel account (via your customer account or https://www.bmoname.com:2083).
In the Files section of your control panel, click your File Manager.
Navigate to the folder or subdomain you want to change the PHP version of. Then find the . htaccess associated with it, or create a new one if necessary.
Modify your .htaccess file to include this code:
<FilesMatch " .(php4|php5|php3|php2|php|phtml) $">
SetHandler application/x-lsphp82
</FilesMatch>
Note that the second line of the code defines the version of PHP that will be used. In the previous example, the code defined version 8.2 as the one to use.
If you want to use another version, you must adjust the code according to your choice. Here are the codes for the different versions of PHP:
PHP version | Code |
---|---|
5.2 | application/x-lsphp52 |
5.3 | application/x-lsphp53 |
5.4 | application/x-lsphp54 |
5.5 | application/x-lsphp55 |
5.6 | application/x-lsphp56 |
7.0 | application/x-lsphp70 |
7.1 | application/x-lsphp71 |
7.2 | application/x-lsphp72 |
7.3 | application/x-lsphp73 |
7.4 | application/x-lsphp74 |
8.0 | application/x-lsphp80 |
8.1 | application/x-lsphp81 |
8.2 | application/x-lsphp82 |
Save the changes to your .htaccess file so that the change takes effect.
Updated on: 17/05/2023
Thank you!