Payments are experiencing issues due to temporary restrictions in Russia. If your payment does not go through, please submit a support request.Our support team is available 24/7 — we are always here to help with hosting and server issues.We are now accepting requests for dedicated server rental and colocation services in our data center.Reminder: we recommend enabling backups for additional data protection.A new VPS/VDS lineup with NVMe storage and improved performance is now available.Maintenance work on some servers has been completed. All services are operating normally.
Article3 min readViews3

Why the PHP Version in the Terminal Differs from the Site Version

Examining CLI and PHP-FPM: How to Check the Command-Line Environment and Understand Why Its Settings Do Not Guarantee Web Request Configuration

Two Computer Environments on a Technical Desktop
In this article

The terminal has the required PHP version installed, but the site continues to report a different one. This is not necessarily an update error. The command line and web server may run different executable files, read different configuration settings, and use different sets of extensions.

Check the Command-Line PHP

On Linux with PHP CLI installed, run:

php -v

php --ini

php -m

These commands show the version, loaded configuration files, and modules specific to this CLI. They are useful for background scripts and tasks that invoke this binary file. However, you cannot transfer this output to the web request handler.

If the system has multiple versions, the short name php is selected from the current session environment. The scheduler or service may use an absolute path to a different version. Compare the actual launch command, not just the result in your personal terminal.

Trace the Web Request Path

When working via PHP-FPM, the web server forwards requests to a specific socket or pool address. You must determine which service handles that pool and identify the settings associated with it. Service names and file locations depend on the distribution and installation method.

Do not select a service based on the highest version number in the list. What matters is the connection: virtual host, upstream address, specific pool, and its process. Multiple sites on a single server may intentionally use different environments.

Compare significant parameters

For a problematic scenario, compile a small set: version, extensions, memory and execution time limits, and file upload settings. There is no need to change all parameters just to achieve a complete match between CLI and FPM, as they may have different operational tasks.

Example: an import via the terminal completes, but launching through the web interface is interrupted. The cause could be a difference in limits, process user, or proxy restrictions. A successful CLI run does not prove that the error lies exclusively in PHP-FPM.

Do not leave a public diagnostic page

Detailed PHP information output can reveal paths, environment variables, and server settings. If a diagnostic mechanism is used to check the web environment, it must be accessible only to the responsible specialist and removed or disabled after verification.

It is preferable to use existing secure diagnostic tools for the CMS or control panel. Publishing an open page with all parameters for a single version creates an unnecessary task for access control and cleanup.

Check background jobs separately

Even after fixing the web pool, the scheduler may continue to run the old CLI. Check the explicit path to the binary file, the user, and the job configuration. Otherwise, the site will run in one environment while the directory exchange runs in another.

After making changes, repeat the scenario where the problem occurred: a web request, import, or background processing. Save the actual versions and settings for each environment. The result should be a clear execution map, not just the same number appearing in several randomly selected commands.

Check the set of extensions separately in each environment. The presence of a module in the CLI does not prove it is loaded in the pool serving the site.

Discussion0

Share your experience and ask questions. Comments without links appear after editorial review.

No comments yet. Start the discussion.