Den här artikeln finns även på Svenska
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
- Regardless of which settings you want to manage, first you need to log on to cPanel for your webhosting account.
Select PHP Versionunder
- You have now reached the interface through which you may manage PHP.
How do I change PHP version?
Which PHP versions are available?
On our webhosting services, Reseller Agency, and Managed Servers (running CloudLinux), you have access to the following PHP versions:
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.
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
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.
When a change has been saved an infobox appears.
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).
After logging on to cPanel and accessing
Select PHP version according to the instructions above, click the
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.
When the value is saved, an infobox will be displayed in the top right corner.
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 wish to edit options. You may create the file with the File Manager built into cPanel. Just remember to activate display of hidden files.
.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
Using PHP via terminal/SSH and cronjobs
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:
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: