• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

Issue Best Practice to Change WP-CLI PHP Version on Production Plesk Server

iGraphics

Basic Pleskian
Server operating system version
AlmaLinux 8.10 (Cerulean Leopard)
Plesk version and microupdate number
Plesk Obsidian 18.0.76 Update #2 Web Host Edition
Hello,


I’m running Plesk on AlmaLinux 8 (production server with multiple client sites).


Websites use PHP 8.4 via PHP-FPM, but WP-CLI is using the system PHP 7.2

Bash:
php -v
PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.4.5, Copyright (c) 2002-2020, by ionCube Ltd.

This causes compatibility issues with modern plugins (e.g., WooCommerce).
What is the recommended and safe way to make WP-CLI use PHP 8.4 system-wide without affecting Plesk core components?

  • update-alternatives?
  • WP_CLI_PHP environment variable?
  • symlink change?
  • Plesk-specific method?

Looking for the safest production approach.
Thank you.
 
Hi, @iGraphics . php -v calls the system PHP version. In order to use a particular Plesk PHP version you will need to specify the full path to the binary file, e.g.:

Code:
/opt/plesk/php/8.3/bin/php <your wp-cli command>

You can check all available Plesk PHP handlers with:

Code:
plesk bin php_handler --list
 
Thank you for the clarification.
I understand that php -v reflects the system PHP version and that specifying the full Plesk PHP binary path (e.g. /opt/plesk/php/8.4/bin/php) is the correct way to run WP-CLI with a specific Plesk-managed PHP version.
Since this is a production server hosting multiple client websites, I want to avoid modifying the system PHP (/usr/bin/php) or using update-alternatives, as that could potentially impact Plesk core components or OS-level dependencies.
To keep the environment clean and safe, I am considering one of the following approaches:
Creating a wrapper script (e.g. wp84) that explicitly calls: /opt/plesk/php/8.4/bin/php /usr/local/bin/wp
Configuring a per-user shell environment so that the correct PHP binary is used when running WP-CLI via SSH.
From a best-practice and long-term maintenance perspective, would you recommend keeping explicit PHP binary paths (or a wrapper) as the standard approach on Plesk production servers?
Appreciate your guidance.
 
Back
Top