How to Locate and Install a PHP Version or Extension
Last modified: September 26, 2024
Overview
EasyApache 4 allows the use of multiple versions of PHP. This document explains how to locate and install a PHP version or a PHP extension.
Determine a user domain PHP version
You can determine a user domain PHP version with one of the following methods:
-
Use WHM’s MultiPHP Manager interface (WHM » Home » Software » MultiPHP Manager). This interface allows you to see and change a user’s default PHP version. This is the easiest method to determine a user’s PHP version.
-
Use cPanel’s MultiPHP Manager interface (cPanel » Home » Software » MultiPHP Manager).
-
Run the following command, where
USERNAME
is the cPanel account username andDOMAIN
is the domain:grep phpversion /var/cpanel/userdata/USERNAME/DOMAIN
The output should resemble the following example:
phpversion: ea-php81
-
Use WHM API 1’s
php_get_vhost_versions
function. -
Use UAPI’s
LangPHP::php_get_vhost_versions
function.
Install a PHP version
EasyApache 4 supports PHP version 7.4 and PHP 8.1 through 8.4.
The cPanel default profile includes PHP versions 8.1 and 8.2.
EasyApache 4 adheres to the php.net supported versions timeline. The profiles that we supply in WHM’s EasyApache 4 interface (WHM » Home » Software » EasyApache 4) only provide PHP versions that php.net currently supports. RPMs for unsupported versions of PHP will remain the WebPros International, LLC mirrors and servers, but we will not provide any further updates.
You can install a PHP version on your system with one of the following methods:
- Use WHM’s EasyApache 4 interface (WHM » Home » Software » EasyApache 4) to select the version of PHP that you wish to load.
Note:
You can only install cPanel-provided PHP packages in the EasyApache 4 interface. You must use a package manager to install custom PHP packages.
- Use your package manager’s
install
command to install your desired PHP version.
Vendor-provided PHP versions
EasyApache 4 allows you to use PHP versions that WebPros International, LLC does not provide on non-Ubuntu systems. These PHP versions must be a Software Collection Library (SCL) package and cannot start with the ea-
prefix that EasyApache 4 uses.
- You cannot use the EasyApache 4 interface (WHM » Home » Software » EasyApache 4) to install vendor-provided versions of PHP. You must use a package manager to install these packages on your system. For more information, read our Package Manager Basics documentation.
- After you install the packages, you can use WHM’s MultiPHP Manager interface (WHM » Home » Software » MultiPHP Manager) and WHM’s MultiPHP INI Editor interface (WHM » Home » Software » MultiPHP INI Editor) to make changes.
- The DSO PHP handler is not available with Red Hat® Enterprise Linux® (RHEL) and CloudLinux™ PHP packages.
- PHP packages require a vendor prefix in order to install in EasyApache 4.
- Not all vendor-provided PHP packages will contain all of the files that EasyApache 4’s MultiPHP system requires. You may experience additional limitations.
Find a PHP module or extension
You can find a PHP module or extension with one of the following methods:
- Use WHM’s EasyApache 4 interface (WHM » Home » Software » EasyApache 4).
- To determine if the package is already installed, run the
rpm -qa | grep -i package
command, wherepackage
represents part of the name of the package that you wish to install. - To determine if the package is available, run the
yum list package
ordnf list package
command, wherepackage
represents part of the name of the package that you wish to install.
Install a PHP module or extension
EasyApache 4’s packages for PHP modules and extensions use the ea-php##-php-module
naming convention, where ##
represents the PHP version number and module
represents the name of the PHP module.
Install a PHP module or extension on your system with one of the following methods:
- Use WHM’s EasyApache 4 interface (WHM » Home » Software » EasyApache 4).
- Install the package on the command line with the following command:
Operating System Command CentOS 7 yum install ea-php82-php-gd
AlmaLinux OS and Rocky Linux™ dnf install ea-php82-php-gd
Ubuntu® apt install --purge ea-php82-php-gd
The above example installs theea-php82-php-gd
package, where82
represents the PHP version andgd
represents the extension name.
When you install a newer version of PHP, the system automatically selects the extensions used with your older versions, if compatible.