How to change the PHP version

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.

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.

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:

Select Php Version

In the next screen, click on the drop-down menu next to the Current PHP version and choose the version you want.

Php Selector

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.

Php Extensions

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. From here it is also possible to enable the display_errors option to display PHP errors on the screen.

Php Options

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:

Select Php Version Per Domain

Then from the drop-down menu beside the PHP version, select the version and click the Apply button.

Set Php Version

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.

The first thing to do is to access the folder you are interested in. You can do this from the cPanel file manager or by connecting via FTP.

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

Show Hidden Files

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:

Create Htaccess File

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

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 version
PHP 4.4AddHandler application/x-httpd-alt-php44 .php .php4 .phtml
PHP 5.1AddHandler application/x-httpd-alt-php51 .php .php5 .phtml
PHP 5.2AddHandler application/x-httpd-alt-php52 .php .php5 .phtml
PHP 5.3AddHandler application/x-httpd-alt-php53 .php .php5 .phtml
PHP 5.4AddHandler application/x-httpd-alt-php54 .php .php5 .phtml
PHP 5.5AddHandler application/x-httpd-alt-php55 .php .php5 .phtml
PHP 5.6AddHandler application/x-httpd-alt-php56 .php .php5 .phtml
PHP 7.0AddHandler application/x-httpd-alt-php70 .php .php7 .phtml
PHP 7.1AddHandler application/x-httpd-alt-php71 .php .php7 .phtml
PHP 7.2AddHandler application/x-httpd-alt-php72 .php .php7 .phtml
PHP 7.3AddHandler application/x-httpd-alt-php73 .php .php7 .phtml
PHP 7.4AddHandler application/x-httpd-alt-php74 .php .php7 .phtml
PHP 8.0AddHandler application/x-httpd-alt-php80 .php .php8 .phtml
PHP 8.01 AddHandler application/x-httpd-alt-php81 .php .php8 .phtml

Try one of our hosting plans for free and without obligation for 14 days. No payment information required!


4 responses to “How to change the PHP version”

  1. deroderuiter Avatar

    When I change .htaccess using the instructions, then I get a 403 error in Joomla

    1. Try using the graphic interface. It’s possibile that the server where you now doesn’t allow it. In that case you can move to SupportHost and enjoy this feature and much more.

  2. jayaprakash Avatar

    how can I use multiple PHP versions? Can I configure various PHP simultaneously and use it for different application folders?. Is there any possibility?

    1. If you use our service you can, just follow the steps in this tutorial. It’s really useful when you have to test different php versions