Page tree
Skip to end of metadata
Go to start of metadata

Overview

PHP is a scripting language that websites often use for applications and content. EasyApache allows you to easily install and modify PHP for your server.

When you install cPanel & WHM, the installation process automatically installs PHP with some common PHP options. 

For more information about the PHP scripting language, read the PHP development website. 

How Apache handles PHP

By default, cPanel & WHM configures your Apache web server to use the CGI handler to handle requests that it receives for PHP content.

Note:

The PHP handler that you select affects the speed and security of your web server. For more information about PHP handlers, read our PHP Handlers documentation.

PHP versions

EasyApache 4 supports PHP versions 5.4, 5.5, 5.6, 7.0, 7.1, and 7.2.

When the PHP development team makes a new version of PHP available, we test and then make the new version available in EasyApache.

Minor version number changes do not impact functionality, but major updates may require changes to your configuration. In many cases, the EasyApache software will make the necessary adjustments automatically. Custom configurations may require further manual adjustments. For more information on PHP versions and extensions available in EasyApache 4, read our  PHP Options documentation. 

MultiPHP

EasyApache 4 supports multiple versions of PHP.

To change your server's default version of PHP or a virtual host's version of PHP, use WHM's  MultiPHP Manager interface (WHM >> Home >> Software >> MultiPHP Manager). 

If the version of PHP that you wish to use does not exist on your server, you can install it with the EasyApache 4 interface (WHM >> Home >> Software >> EasyApache 4). To install your PHP version with yum, read our How to Locate and Install a PHP Version or Extension documentation. 

Vendor-provided PHP versions

In cPanel & WHM version 66 and later, EasyApache 4 allows you to use PHP versions that cPanel, Inc. does not provide. 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 yum to install these packages on your system. For more information, read our Yellowdog Updater, Modified (yum) 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. 

Important:

  • The DSO PHP handler is not available with Red Hat® Enterprise Linux® (RHEL) and CloudLinux™ PHP packages.
  • SCL PHP packages require a vendor prefix in order to install in EasyApache 4. For example, you cannot use RHEL PHP versions 5.4 or 5.5 because these packages do not begin with a vendor prefix. 
  • Not all vendor-provided PHP packages will contain all of the files that EasyApache 4's MultiPHP system requires. You may experience additional limitations.


Potential issues

Some potential issues exist in vendor-provided versions of PHP.

Vendor-provided php.ini does not exist

In some cases, a vendor-provided PHP version's php.ini file will not exist in the directory that cPanel & WHM requires. For example, RHEL's php56 .ini file exists in the /opt/rh/rh-php56/register.content/etc/opt/rh/rh-php56 directory, but cPanel & WHM expects it in the /opt/rh/rh-php56/root/etc directory. You must create a symlink in order for the MultiPHP system to read the php.ini file.

To create the symlink, use the following command, where php56 represents the PHP version that you wish to use:

ln -s /opt/rh/rh-php56/register.content/etc/opt/rh/rh-php56 /opt/rh/rh-php56/root/etc 

If you installed the PHP version before you created the symlink, you must reinstall the PHP version with the following command, where php56 represents the PHP version that you wish to use:

yum reinstall rh-php56*
PHP CLI and PHP CGI binaries in different locations

Some PHP versions include the PHP CLI and PHP CLI binaries in different locations than cPanel & WHM's implementation. In these cases, the PHP installation reverses the location of these binaries. If your PHP version does this, then the following issues may occur:

  • The php-cgi binary path will not exist.
  • The php-cli binary path will be incorrect.

To fix this issue, use the following commands, where prefix represents the vendor prefix and package represents the package name:

mv /opt/prefix/package/root/usr/bin/php /opt/prefix/package/root/usr/bin/php-cgi
mv /opt/prefix/package/root/usr/bin/php-cli /opt/prefix/package/root/usr/bin/php

Modify PHP

There are several methods that allow you to modify your PHP configuration. For more information, read the following documentation:

  • PHP Options — A list of the available options in EasyApache that directly modify PHP.
  • PHP Handlers — The PHP handler that you select determines how Apache handles requests for PHP content.

To more easily allow you to call the PHP binaries directly, we provide the following symlinks for each version of PHP installed on your system:

  • PHP CLI — /usr/local/bin/ea-php##, where ## represents the two-digit PHP version.
  • PHP CGI — /usr/bin/ea-php## command, where ## represents the two-digit PHP version.

Adjust configuration files

To further customize your PHP configuration, you can edit your .ini files. We strongly recommend that you only edit your configuration files in cPanel's  MultiPHP INI Editor interface (cPanel >> Home >> Software >> MultiPHP INI Editor). To edit your files manually, use the following files in your document root:

Apache handlerPHP configuration file
suPHP

.user.ini

Note:

 If you enabled the suPHP_ConfigPath directive in your .htaccess file, read our The cPanel PHPRC PHP Patch for EasyApache 4 documentation.

CGIphp.ini
DSO.htaccess


PHP Security

To ensure that your PHP stays up to date, use one of the following options:

  • Set the Operating System Package Updates section of WHM's Update Preferences interface (WHM >> Home >> Server Configuration >> Update Preferences) to Automatic
  • As a root-enabled user, run yum update on the command line. 
  • Install the CentOS-provided yum-cron package with the following command: yum install yum-cron.

For more information about PHP security, read the following documentation:

Additional documentation