Change PHP Standard CLI Version
This article explains how to change the default PHP CLI binary for an SSH user (system user). Please make sure that you use the shell /bin/bash
for the system user.
Change PHP CLI version
First log in via SSH with the relevant SSH user (system user). You can then use the following command to change the default PHP version:
echo "export PATH=/opt/plesk/php/8.2/bin:$PATH;" >> ~/.bash_profile
source ~/.bash_profile
You can use the command php -v
to check whether 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. Via the command
plesk bin php_handler --list
all versions can be displayed:
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:
``bash 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 )
<br>
---
## Common errors
Error message:
```bash
/usr/bin/env: "php": File or directory not found
This error occurs if no standard PHP CLI version has been selected. In this case, you can either store 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