1. Home
  2. cPanel/WHM
  3. How do I manage PHP?

How do I manage PHP?

Den här artikeln finns även på svSvenska

Via cPanel, you can manage a vast amount of settings for PHP; what version you use, which extensions that are active and which options should be used. In this guide, we will walk you through all of these.

Access to the settings

  1. Regardless of which settings you want to manage, first you need to log on to cPanel for your webhosting account.
  2. Click Select PHP Version under Software.
    Link to PHP Version module
  3. You have now reached the interface through which you may manage PHP.

How do I change PHP version?

Before you change, remember to check that the PHP version you choose is compatible with the software that you are running, for example the version of WordPress or Joomla that you are using. Information about this is available from each developers’ web site.

It is possible at any time to change back to the version you used earlier if it turns out that your web site did not work after the change.

Which PHP versions are available?

On our webhosting services, Reseller Agency, and Managed Servers (running CloudLinux), you have access to the following PHP versions:

  • 5.2
  • 5.3
  • 5.4
  • 5.5
  • 5.6
  • 7.0
  • 7.1
  • 7.2
  • 7.3
  • 7.4
  • 8.0

Each version is being held updated with bug fixes and security updates. Even the older versions that no longer are being supported by the PHP community receive security updates from us.

Please note that if you have an non-managed VPS it is up to you to install and manage the PHP versions being available on the server.

If you run a server with cPanel, it is possible to buy CloudLinux as an addon, or you can use the built-in MultiPHP function.

Global version setting

After logging on to cPanel and accessing Select PHP version according to the instructions above, you can both see the currently active PHP version (marked current), and via the dropdown menu see the available PHP versions.

Select the version you like to run and click Set as current. You are now using the selected version, but you may need to reload the page to see your newly selected version as the current one.

Local version setting

You can set a specific PHP version for a single folder on you account. This way you can run different versions of PHP for different parts of your account even though the global setting is set to another version.

To do this you have to edit the .htaccess-file that is in the folder for which you want to set a PHP version for. If the .htaccess file does not exist you can create it. You can do this using for example the File Manager in cPanel (remember to activate viewing of hidden files if you are using the File Manager).

When you have opened the .htaccess file for editing you will have to enter this code at the top of the file:

AddHandler application/x-httpd-alt-php73___lsphp .php .php7 .phtml

73 means PHP 7.3, replace it with the version you want to use, for example 56, 72, and so on.

How do I managed PHP extensions?

You can manage your PHP extensions from within cPanel. Some examples of PHP extensions are opcache, mysqli, imagick and soap.

Begin with accessing cPanel -> Select PHP version according to the instructions above.

On the lower half of the page, you should see a large amount of checkboxes. Each one represents a different PHP extension. To activate it, you tick the box next to the extension name and to deactivate you untick it. Changes are saved automatically.

Select PHP modules

When a change has been saved an infobox appears.

Change of PHP module saved

How do I manage PHP options?

Sometimes you may want to adjust specific settings for PHP, and on our servers this can be done in two ways; either via cPanel, or via a .user.ini file which you create on the account (on other servers this can be done via a php.ini file, but we do not use that system).

Via cPanel

After logging on to cPanel and accessing Select PHP version according to the instructions above, click the Options tab.

There you may do your changes to the options by clicking on the values in the table. When you edit an option, the settings will save automatically.

Lista över PHP-inställningar

When the value is saved, an infobox will be displayed in the top right corner.

PHP-inställning ändrad

Via .user.ini

You can also set PHP options via a .user.ini file on your webhosting account. Start with creating a file which you name .user.ini in the folder where the website is residing for which you wishes to edit options. You may create the file with the File Manager built into cPanel. Just remember to activate display of hidden files.

Into the .user.ini file you may then put all PHP options you want to edit. The settings will act on the folder where the file is placed and all subdirectories. E.g. if you want to adjust the amount of memory each PHP process can access, you add this to the file:

memory_limit = 1024M

Settings you cannot set via .user.ini

Not all PHP options are ajustable via .user.ini, you can find a list from php.net here. Only settings marked with changable: PHP_INI_ALL and PHP_INI_PREDIR is possible to set via .user.ini.

Using PHP via terminal/SSH and cronjobs

If you want to run PHP commands or scripts via the terminal or SSH, or via cronjobs, you can enter the path to PHP in a few different ways.

Using the global setting for PHP version

If you wish to run a PHP command or script using the PHP version globally set for your web hosting account, enter the command in one of the following ways:

php /home/yourusername/path_to_the_script.php


/usr/local/bin/php /home/yourusername/path_to_the_script.php

If you want to access your PHP script via a cronjob, you should use the latter version of the command.

Using a specific version of PHP

If you on the other hand want to specify the PHP version for your PHP command or script, you need to run the command in the following manner instead:

/opt/alt/php73/usr/bin/php /home/yourusername/path_to_the_script.php

By swapping out 73 in the command above you can determine what PHP version to use. For instance, if you want to use PHP 7.0, change it to 70.

Was this article helpful?

Related Articles