Changing your PHP Version, PHP Extensions, PHP Functions and PHP Options

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.

PHP settings apply for the whole cPanel account - including any addon, alias and subdomains. So, if you have multiple sites running on different domains within the same account please be sure to test them all thoroughly when changing the PHP version or making other changes. You can switch back to a previous PHP version if there's a problem.

Changes to any of these settings - PHP Version, 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 page on the PHP Extensions tab. The current PHP version is shown at the top and indicated with (current).

To change the PHP version for this cPanel - click the current version and select the required version from the drop-down and then click Set as Current.

After changing the PHP version please ensure all required PHP Extensions are enabled and that your PHP Options settings are correct - checking and changing these are covered next in this guide.

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 Extensions

What is a PHP extension?

A PHP extension (sometimes also called PHP Module), as its name suggests, extends the PHP language with more functions. For example, the Imagick 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 PHP Extensions available, with the system default modules for that version selected. You can see them for PHP 7.3 in the screenshot above. You can enable modules by ticking, disable by unticking - changes will automatically save. You'll see a notification box confirming your actions at the top of the screen.

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 can cause intermittent or permanent errors or performance degradation - for example, the APC extension should not be used with PHP 5.4 and above.

Conversely, failing to select PHP extensions that are required by your web application can cause server errors and prevent it from working at all.

IonCube loader is required for WHMCS - you can enable that here.

Changing PHP options

The PHP Options tab allows you to easily change a number of the common php.ini settings, without having to edit the php.ini file.

The options available here include date.timezone, max_execution_time, memory_limit and more.

To change an option you need to either click on its current value or check/un-check it's tick box - 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 the following PHP functions are disabled. They can be found in the disabled_functions option.

system
system_exec
symlink
shell
shell_exec
exec
passthru
escapeshellarg
escapeshellcmd
proc_close
proc_open
ini_alter
dl
show_source
proc_get_status
proc_nice
proc_terminate
highlight_file
define_syslog_variables
posix_uname
posix_getpwuid
apache_child_terminate
posix_kill
posix_mkfifo
posix_setpgid
posix_setsid
posix_setuid
ini_restore
inject_code
define_syslog_variables
apache_setenv
eval
phpAds_XmlRpc
phpAds_remoteInfo
phpAds_xmlrpcEncode
phpAds_xmlrpcDecode
xmlrpc_entity_decode

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.

IMPORTANT SECURITY NOTE: To avoid compromising security, disable_functions should only be changed with caution and only if you are sure of what you are doing. Modern PHP web applications intended for shared hosting environments are unlikely to need any adjustments to this setting. Please ask for advice if you are unsure.

php.ini files

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.

You can 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.


How did we do?


Powered by HelpDocs (opens in a new tab)
© Krystal Hosting Ltd 2003–2019