Chat / support@radicenter.eu

PHP versions and using/modifying those on cPanel servers

Couple of customers have asked us possibility to change domains PHP version in cPanel webhosting account.
This is supported in cPanel and also thru commandline or via .htaccess file:

NB! differences in PHP versions:
– After 05.04.2021 default PHP version on our servers (instead of 7.2) is PHP 7.4 !
– PHP 8.0 version does not have iMagick class nor Ioncube loader support (Checked on 18.03.2021 – those addons still lack support for PHP 8.0)!

Additional info:
WordPress and Joomla CMS have started to show “security notification” in admin panel when older PHP version is in use.
We use on our servers separate PHP versions in which even older versions still get security patches and updates.
You can read more info regarding this on page:
https://www.cloudlinux.com/hardenedphp
(If Your webpage/script/etc supports newer PHP versions, I would recommend to update Your domain to newest PHP version supported!)

1. Changing PHP version in cPanel
2. Changing PHP version via .htacces file
3. Examples how to run script with required PHP version via commandline (Works also via CRON)
4. Saving PHP errors to error_log file

1. Changing PHP version in cPanel

1. Log on to Your cPanel webhosting account
2. Select “MultiPHP manager”
3. Select domain, select required PHP version from dropdown on the right and click “Apply”
(New PHP version will be activated automatically shortly after save)
NB! Mentioned save action will overwrite PHP version in .htaccess file! If You remove/have removed those changes manually, You need to re-apply them!

2. Changing PHP version via .htacces file

1. Add .htaccess file to Your domains root folder (if that file is not yet present there!)
2. Add to the beginning of the file code:

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php00” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php00___lsphp .php .php0 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

In where You must replace the version 00 and 0 with Your required PHP version.
Available versions are: 5.3 = 53 , 5.6 = 56 , 7.0 = 70, 7.1 = 71, 7.2 = 72, 7.3 = 73, 7.4 = 74, 8.0 = 80

3. Examples how to run script with required PHP version via commandline (Works also via CRON)

Example commands to use with script:

Cronis:
/usr/local/bin/ea-php53 /path/to/required/script.php
/usr/local/bin/ea-php56 /path/to/required/script.php
/usr/local/bin/ea-php72 /path/to/required/script.php
/usr/local/bin/ea-php74 /path/to/required/script.php
/usr/local/bin/ea-php80 /path/to/required/script.php
----
Commandline:
php -ea_php 53 /path/to/required/script.php
php -ea_php 56 /path/to/required/script.php
php -ea_php 72 /path/to/required/script.php
php -ea_php 74 /path/to/required/script.php
php -ea_php 80 /path/to/required/script.php

NB! If in required folder or subfolder allready has .htaccess file with required PHP version, there is no need to separately give php command exact version, just “php /path/to/required/script.php” will suffice

4. Saving PHP errors to error_log file

1. Log on to Your cPanel webhosting account
2. Select “MultiPHP INI Editor”
3. Select “Editor Mode”
4. From dropdown, select required domain, to where there is need to apply those changes
5. Add code:

error_log = "/home/npXXXXXXX/logs/yourdomain_tld.error_log"
log_errors = On

Where “npXXXXXXX” must be changed to Your cPanel account username and “yourdomain_tld” replaced with Your domain name and save changes.
Upon any errors, those are saved to error_log file to Your account home folder under logs folder.

Comments are currently closed.

This website utilizes cookies and similar technologies for functionality and other purposes. Your use of this website constitutes your acceptance of cookies.
Ok, got it.