Couple of customers have asked us possibility to change domains PHP version in cPanel webhosting account.
This is supported in cPanel and also thru command line 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)!
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:
(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
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. Examples how to run script with required PHP version via command line (Works also via CRON)
Example commands to use with script:
In cron: /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 ---- In command line: 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
3. 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