EasyApache 4 and the ea-php-cli Package


Last modified: March 12, 2024

Overview

The ea-php-cli package is EasyApache 4’s replacement for the system-provided /usr/bin/php binary. This package determines the PHP version that the user’s application requires from the system. While the stock version of the /usr/bin/php binary assumes a single version of PHP, cPanel & WHM’s ea-php-cli package determines the correct version of PHP to execute.

What do the ea-php-cli packages do?

The ea-php-cli package installs the following PHP binaries:

  • /usr/bin/php — This executable uses the php-cgi binary for the specified PHP version.
  • /usr/local/bin/php — This executable uses the php-cli binary for the specified PHP version.

When you install a PHP version, the system also installs the ea-php-cli-lsphp package. This package contains the /usr/bin/lsphp binary. This executable uses the lsphp (Litespeed) binary for the specified PHP version.

Note:

The ea-php-cli-lsphp package manages this binary. If you can not call this binary, you can install it manually with the following command:

Operating SystemCommand
CentOS 7yum install ea-php-cli-lsphp
AlmaLinux OS and Rocky Linux™dnf install ea-php-cli-lsphp
Ubuntu®apt install --purge ea-php-cli-lsphp

These binaries ensure that your system uses the correct PHP handler for your request.

What is the difference between the two directory paths?

The /usr/bin/php binary calls the PHP CGI handler. The /usr/local/bin/php binary calls the PHP command-line handler. This works with most system’s default PATH settings, and ensures compatibility with EasyApache 3 behavior.

What is lsphp?

The /usr/bin/lsphp binary calls the Litespeed (lsphp) binary. This works with most system’s default PATH settings and ensures that the system correctly calls Litespeed.

Note:
You can also use /usr/local/bin/lsphp to call this binary.

The system default PHP configuration file

The system uses the /etc/cpanel/ea4/php.conf file to determine the system’s default PHP version and the PHP handler that each PHP version uses.

If a PHP file’s PHP version is not explicitly set, the system uses the default entry in the /etc/cpanel/ea4/php.conf file to determine which version of PHP to use.

Set the system’s default PHP version and an individual domain’s PHP version in WHM’s MultiPHP Manager interface (WHM » Home » Software » MultiPHP Manager). You can also set the system’s default PHP version with the /usr/local/cpanel/bin/rebuild_phpconf script. For more information, read our PHP documentation.

  • If you configure a file or the system with an invalid package, the executable exits with an error message.
  • If you configure the file or system with a package that does not contain the necessary binary, the executable displays a warning message and uses the system default version of PHP.
  • If both a file’s configured version of PHP and the system default version of PHP are unavailable, the executable exits with an error.
Important:
If you manually edit the php.conf file, your settings may not persist.

How to call the ea-php-cli binaries

To call the ea-php-cli binaries, run the one of the following commands, where filename.php represents the file that you wish to process:

  • /usr/bin/php <options> filename.php
  • /usr/local/bin/php <options> filename.php
  • /usr/bin/lsphp <options> filename.php

To run PHP from the command line, your command might resemble the following example:

/usr/bin/php /home/bob/public_html/domain/app/periodic_job.php

The system uses the user’s configured PHP path to determine which PHP version it calls.

The first time you call one of the ea-php-cli binaries, the system creates the .ea-php-cli.cache symlink to the PHP version that the directory requires. This symlink provides a quick way for the system to determine the proper version of PHP and reads as broken by design. For example, if the PHP script requires PHP 7.0, then the symlink will point to ea-php70.

Important:

We strongly recommend that you do not delete these symlinks. The system creates broken symlinks by design and will recreate any removed symlinks the next time that you run the script. You can safely ignore them.

Override the default ea-php-cli behavior

If you want to override the file’s configured version of PHP, use the /usr/bin/ea-php## symlink, where ## represents the two-digit PHP version that you wish to use. Your command might resemble the following example:

/usr/bin/ea-php72 filename.php

If you want to override the file’s configured version of PHP with a custom .ini file, run the following command, where ## represents the two-digit PHP version that you wish to use:

ea-php70 -c /custom/directory/custom-file.ini my_script.php

You can also use the --ea-reference-dir=directory option to tell the system to use the PHP version set in the specified directory. Your command might resemble the following example, where directory represents the path to the directory that you wish to reference:

/usr/bin/php --ea-reference-dir=directory /usr/local/share/whatever.php
Note:

We deprecated the -ea_php option in the ea-php-cli version 1.0.0 RPM. We will remove this option in November 2019.

The system passes all other options that you provide to the PHP binary.

For more information, read our PHP Home documentation.

Additional Documentation