How to change PHP version and update PHP extensions on Shared servers Print

  • 2

Change PHP version and/or manage extensions

1. Log into your cPanel account.
2. Scroll down to the SOFTWARE section >> Select PHP Version:
For cPanel Basic Theme:


3. Here you will see the list of available modules and extensions.

If you do not need to change the PHP version and just want to turn on/off specific extensions, you can do this by checking/unchecking the corresponding boxes.

Use the PHP Version drop-down box to select the required version, click on Set as current in order to apply the changes.

NOTE: The 'native' PHP version does not allow changing any options. You can set the desired values using a php.ini file:

4. To change individual settings within the PHP version in question, click on Switch to PHP Options.

By clicking on one of the options in grey, you will be presented with a drop-down list to change specific settings. Hit Apply to implement the settings:

NOTE 1: If you used a php.ini file for editing your account PHP configuration before, you will need to replicate the custom values using PHP Selector tool.

NOTE 2: 
In order to increase the max upload size, make sure to modify both post_max_size and upload_max_filesize values.

NOTE 3: max_execution_time can be increased up to 300 seconds.

Change PHP version for addon domain

Sometimes your website may need to use a different PHP version from the one assigned to your domain on your cPanel account.

To set a different PHP version for an addon domain, you need to add a special code to your .htaccess file. To do this, follow the steps below.

1. Find the .htaccess file for the addon domain in question.

2. Add the following line to your .htaccess file:

<FilesMatch ".(?:html|php)$">
SetHandler application/x-lsphpXX

where XX is the PHP version you wish to set. It can be 52, 53, 54, 55, 56, 70, 71,72, or 73.

For example:

3. Click “Save changes”.        

NOTE: When a different PHP version is set for the addon domain, there are no PHP extensions enabled by default. To make a website work correctly, you will need to upload a php.ini file to the folder of the addon domain. (see point 6) to help you with uploading files to the hosting account.

You can download the php.ini file for different PHP versions from the Attachments section at the end of this guide. Do not forget to rename the file to php.ini once it is uploaded to the hosting account.

Alternatively, you can run the command below via SSH:

cp /opt/alt/default_php_ini/phpXX.ini /home/cPanel_username/path_to_the_folder/php.ini

  • XX is PHP version you wish to set (it can be 52, 53, 54, 55, 56, 70, 71, 72 or 73),
  • cPanel_username should be replaced with your actual cPanel username, and
  • path_to_the_folder is a path to the folder of the addon domain.

For example:

The process is similar if you wish to set a different PHP version for a subdomain.
That's it!

Was this answer helpful?