Changing your PHP version, modules, settings and functions
PHP originally stood for Personal Home Page, but it now stands for the recursive acronym 'PHP: Hypertext Preprocessor'.
PHP is a programming language and forms the basis of many modern content management systems like WordPress, Joomla and Drupal.
This article describes how to change a cPanel account's PHP version, add or remove PHP modules, change PHP options and how to enable functions. All actions are completed within cPanel for the domain you wish to change.
Changes to any of these settings - PHP version, modules/extensions & options - take effect virtually instantly. See the section below on Checking your current PHP settings.
PHP settings are accessed via cPanel > Software > Select PHP Version
Changing your PHP version
When you click 'Select PHP Version' you will be presented with the PHP Selector extensions page. The option to change PHP version is the drop-down at the top left - once you've selected the version you require, click 'Set as current'. Changing the PHP version is also available at the top of the PHP Selector options page - and works in the same way.
Whilst we would always recommend running the latest version of PHP possible (v7.x has significant performance improvements over v5.x - so you could get a 'free' website speed boost just by changing) - we do also offer hardened and security patch maintained older versions if your website requires them.
Changing PHP Modules/Extensions
What is a PHP extension?
A PHP extension, as its name suggests, extends the PHP language with more functions. For example, the gmagick extension - external link opens in a new window provides a range of PHP functions relating to image manipulation. If you attempt to use any of these functions without activating this extension then your pages will return an internal server error.
For example, Magento has a list of required PHP Extensions - external link opens in a new window listed including DOM, and soap, which may not be enabled by default.
Enabling and disabling a module/extension
Depending on the PHP version you select you will see the modules/extensions available, with the default modules for that version selected. You can see them for PHP 5.6 in the screenshot above. You can enable modules by ticking, disable by unticking - changes will automatically save.
Selecting unnecessary PHP extensions to load at run-time can adversely affect the performance of your website because the server has to open more files in order to process your scripts.
This functionality should be used with care. Selecting incompatible extensions (for example, the apc extension should not be used with PHP 5.4 and above) can cause intermittent or permanent errors or performance degradation.
Conversely, failing to select PHP extensions that are required by your web application can cause server errors and prevent it from working at all.
Changing PHP options
The PHP Selector options page allows you to easily change a number of the common php.ini settings, without having to edit the php.ini file.
You can switch to the PHP Selector options page by clicking the link 'Switch to PHP Options' at the top of the PHP Selector extensions page. Once on the PHP Selector options page this link changes to 'Switch to PHP Extensions'.
To change an option you need to click on it's value e.g. to change allow_url_fopen you would click on 'On' - this will then either show you a drop-down of choices or allow you to edit the field depending on the option. Changes you make will be saved automatically.
Unless you have a specific issue the default settings are normally fine.
Please read the following section for more details on changing disabled_functions.
Enabling PHP functions
By default a number of PHP functions are disabled. They can be found in the disabled_functions option.
To enable a function you should remove it from this comma separated list. Be careful to ensure you don't leave any spaces and that there are single commas between each remaining function. Clicking outside the field or navigating away will save any changes.
Any php.ini files that are placed inside your website are ignored by the server for security reasons.
Checking your current PHP settings
If you want to know what settings are in effect on your server, then create a php file containing the following code and browse to it using a web browser.
<?php phpinfo(); ?>
The page will return all of the PHP environment settings, and module information.
e.g. use File Manager to create a new file called
phpinfo.php inside your
public_html directory - then edit that file and copy/paste in the code above and save the file. You can now view this file at https://<your-domain>/phpinfo.php - replacing <yourdomain> with your primary domain served from public_html.