Linux : How to add new version of PHP on CloudLinux PHP Selector

By | July 15, 2022

Everyone used to cPanel is used to the traditional installation with EasyApache (ea-php). However, PHP Selector works differently and use “alt-php” packages. Here is how to add the missing/latest versions to PHP Selector :

1. Make sure you have a complete backup first (yes, I’ve stated the obvious!) ;

2. Login to your server using SSH and execute the following command as root or with sudo priviledges ;

yum groupinstall alt-php

3. Inspect the Yum update summary before hitting the “Y” key :

  • Make sure there is no cross-repo mix-and-match (only packages from CloudLinux repository should show up, if you see packages from other repos make sure to disable any non-standard repo first and start again if this is your case) ;
  • Make sure that no current package is schduled to be removed, if any, investigate first ;
  • If any dependencies are scheduled to be installed, make sure this won’t conflict with anything else on your server (it is common to see added dependencies such as “alt-php*-mariadb*” which is fine.

4. Once ready, just press yes (Y) key and wait for download and install to complete.

NOTE: It isn’t uncommon to see some cosmetic errors related to some configuration PHP handlers unrelated to the version you are installing – example :

info [009-phpconf] Error updating user package handlers for alt-php56: Cpanel::Exception::DomainNameNotAllowed/(XID 6szn78) The supplied domain name is invalid.
at /usr/local/cpanel/Cpanel/WebServer/Userdata.pm line 391.

This is unrelated to the work you just done and could have been caused by several past issues, such as invalid domain name, manually tampering with the configuration outside of cPanel, etc. This won’t impact this particular activity but should still be investigated.

5. All done, you should now see the new versions of PHP in Selector.