Changing the Default PHP CLI Version
This article explains how to change the default PHP CLI binary for an SSH user (system user). Please make sure that the system user is using the /bin/bash shell.
Changing the PHP CLI Version
First, log in via SSH using the relevant SSH user (system user). You can then change the default PHP version using the following command:
echo "export PATH=/opt/plesk/php/8.2/bin:$PATH;" >> ~/.bash_profile
source ~/.bash_profile You can use the php -v command to verify that the changes have been applied correctly.
ssh_demo@s13311:~$ php -v
PHP 8.2.6 (cli) (built: May 12 2023 07:48:41) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.6, Copyright (c) Zend Technologies
with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies Alternative CLI Versions
In addition to PHP 8.2, other PHP versions are also available for the command line. You can list all versions using the command
plesk bin php_handler --list:
plesk bin php_handler --list
id: display name: full version: version: type: cgi-bin: php-cli: php.ini: custom: status:
plesk-php74-cgi 7.4.30 7.4.30 7.4 cgi /opt/plesk/php/7.4/bin/php-cgi /opt/plesk/php/7.4/bin/php /opt/plesk/php/7.4/etc/php.ini true disabled
plesk-php74-fastcgi 7.4.30 7.4.30 7.4 fastcgi /opt/plesk/php/7.4/bin/php-cgi /opt/plesk/php/7.4/bin/php /opt/plesk/php/7.4/etc/php.ini true disabled
plesk-php74-fpm 7.4.30 7.4.30 7.4 fpm /opt/plesk/php/7.4/sbin/php-fpm /opt/plesk/php/7.4/bin/php /opt/plesk/php/7.4/etc/php.ini true enabled
plesk-php74-fpm-dedicated 7.4.30 7.4.30 7.4 fpm /opt/plesk/php/7.4/sbin/php-fpm /opt/plesk/php/7.4/bin/php /opt/plesk/php/7.4/etc/php.ini true disabled
plesk-php80-cgi 8.0.21 8.0.21 8.0 cgi /opt/plesk/php/8.0/bin/php-cgi /opt/plesk/php/8.0/bin/php /opt/plesk/php/8.0/etc/php.ini true disabled
plesk-php80-fastcgi 8.0.21 8.0.21 8.0 fastcgi /opt/plesk/php/8.0/bin/php-cgi /opt/plesk/php/8.0/bin/php /opt/plesk/php/8.0/etc/php.ini true disabled
plesk-php80-fpm 8.0.21 8.0.21 8.0 fpm /opt/plesk/php/8.0/sbin/php-fpm /opt/plesk/php/8.0/bin/php /opt/plesk/php/8.0/etc/php.ini true enabled
plesk-php80-fpm-dedicated 8.0.21 8.0.21 8.0 fpm /opt/plesk/php/8.0/sbin/php-fpm /opt/plesk/php/8.0/bin/php /opt/plesk/php/8.0/etc/php.ini true disabled
plesk-php81-cgi 8.1.8 8.1.8 8.1 cgi /opt/plesk/php/8.1/bin/php-cgi /opt/plesk/php/8.1/bin/php /opt/plesk/php/8.1/etc/php.ini true disabled
plesk-php81-fastcgi 8.1.8 8.1.8 8.1 fastcgi /opt/plesk/php/8.1/bin/php-cgi /opt/plesk/php/8.1/bin/php /opt/plesk/php/8.1/etc/php.ini true disabled
plesk-php81-fpm 8.1.8 8.1.8 8.1 fpm /opt/plesk/php/8.1/sbin/php-fpm /opt/plesk/php/8.1/bin/php /opt/plesk/php/8.1/etc/php.ini true enabled
plesk-php81-fpm-dedicated 8.1.8 8.1.8 8.1 fpm /opt/plesk/php/8.1/sbin/php-fpm /opt/plesk/php/8.1/bin/php /opt/plesk/php/8.1/etc/php.ini true disabled For example, to use PHP 8.1 as the default binary, you can use the command from Step 2 as follows:
echo "export PATH=/opt/plesk/php/8.1/bin:$PATH;" >> ~/.bash_profile
php -v
PHP 8.1.8 (cli) (built: Jul 8 2022 13:47:28) ( NTS ) Common Errors
Error message:
/usr/bin/env: "php": No such file or directory This error occurs if no default PHP CLI version has been selected. In this case, you can either set the default CLI version or call the PHP binary directly. Example:
/opt/plesk/php/8.1/bin/php [your command] See also: PHP CLI Versions