Let’s see how you can change the PHP version from cPanel with a few simple steps.
From cPanel, it is possible to change the PHP version by setting one version for the whole site, or you can also set a different version for each folder or subdomain. We will look at these three methods, but first, let’s see where to find information about the current PHP version.
After logging in to cPanel, click on Server Info from the right-side panel on the cPanel main page to check the current PHP version, where it says Server information.
On the next page, along with other server information, such as the Kernel version or your IP address, you will also see the PHP version.
Change the PHP version
To change the PHP version, you need to access the cPanel and scroll down to the Software section. From here, you will have to click on Select PHP Version, as you see indicated in this screen:
In the next screen, click on the drop-down menu next to the Current PHP version and choose the version you want.
After that, you will need to click on Set as current.
From the PHP Selector, by clicking on the Extensions tab, you can also manage the extensions to activate or deactivate the different available PHP modules.
From the Options tab, on the other hand, you can access several parameters that can be managed, for example, by changing the memory limit or setting a maximum limit for the uploaded files.
Use the MultiPHP Manager
In fact, from the MultiPHP Manager, you can set a different PHP version for each domain (or subdomain).
The MultiPHP Manager tool is located in the Software section of the cPanel. After opening it, you will find yourself in front of the list of domains associated with your account.
Select the subdomain, as in our example, (or the domain) for which you want to change the PHP version by checking the box next to it:
Then from the drop-down menu beside the PHP version, select the version and click the Apply button.
If you have created a site staging environment on a subdomain or have a multidomain account, you can choose to set up different PHP versions with a tool in cPanel.
Change the PHP version for a folder using .htaccess
It is also possible to set different PHP versions by folder. You might need it if you require to use a script that needs a different PHP versions.
To do this, we can use the .htaccess file.
If there is no .htaccess file inside the folder yet, you will need to create one first. Otherwise, you must edit the existing one.
Remember that the .htaccess file is not visible, and to see hidden files you will need to modify the settings. Just click on Settings at the top right of the cPanel and then check the item Show hidden files (dotfiles).
If you need to create the file, just click on File, and then enter the .htaccess file name in the field as you see in this screen:
After creating it, you can edit the file by right-clicking on it and then on Edit.
The file editor will then open where you can enter these instructions to set a specific PHP version. In our example, we set the PHP 5.4 version in a single folder by adding this code in the .htaccess file:
<IfModule mime_module> AddHandler application/x-httpd-alt-php54 .php .php5 .phtml </IfModule>
You can use this method for any PHP version you want to use. Change the middle line to one of these according to the version you want to use.
|PHP 4.4||AddHandler application/x-httpd-alt-php44 .php .php4 .phtml|
|PHP 5.1||AddHandler application/x-httpd-alt-php51 .php .php5 .phtml|
|PHP 5.2||AddHandler application/x-httpd-alt-php52 .php .php5 .phtml|
|PHP 5.3||AddHandler application/x-httpd-alt-php53 .php .php5 .phtml|
|PHP 5.4||AddHandler application/x-httpd-alt-php54 .php .php5 .phtml|
|PHP 5.5||AddHandler application/x-httpd-alt-php55 .php .php5 .phtml|
|PHP 5.6||AddHandler application/x-httpd-alt-php56 .php .php5 .phtml|
|PHP 7.0||AddHandler application/x-httpd-alt-php70 .php .php7 .phtml|
|PHP 7.1||AddHandler application/x-httpd-alt-php71 .php .php7 .phtml|
|PHP 7.2||AddHandler application/x-httpd-alt-php72 .php .php7 .phtml|
|PHP 7.3||AddHandler application/x-httpd-alt-php73 .php .php7 .phtml|
|PHP 7.4||AddHandler application/x-httpd-alt-php74 .php .php7 .phtml|
|PHP 8.0||AddHandler application/x-httpd-alt-php80 .php .php8 .phtml|