It may be useful on Linux set default PHP version for terminal, different from the current one, to install software that requires specific versions of PHP
It is possible to change the default php version from the terminal by following a few simple steps.
Check the current version of PHP
php -v
List all PHP handlers on the server
/usr/local/psa/admin/bin/php_handlers_control --list
and choose one, in our case we will opt for /opt/plesk/php/7.4
Backup old Symlink
As a first step, before setting the default PHP version for the terminal on Linux, make a backup copy of all Symlinks to avoid any loss of data and have the ability to go back
mv /usr/bin/php /usr/bin/php.backup mv /usr/bin/php-cgi /usr/bin/php-cgi.backup mv /sbin/php-fpm /sbin/php-fpm.backup
Linux set the default PHP version for the terminal
Create new Symlinks in Linux to point to the new version of PHP we chose earlier
ln -s /opt/plesk/php/7.4/bin/php /usr/bin/php ln -s /opt/plesk/php/7.4/bin/php-cgi /usr/bin/php-cgi ln -s /opt/plesk/php/7.4/sbin/php-fpm /sbin/php-fpm
Default PHP version in the terminal
As a first step, verify that the changes made were successful by searching by returning the current version of PHP
php -v
Reloading the Plesk database with PHP version changes
/usr/local/psa/admin/bin/php_handlers_control --reread
If everything runs smoothly, don’t forget to delete the backup Symlinks made earlier to keep the binaries folder clean
rm /usr/bin/php.backup rm /usr/bin/php-cgi.backup rm /sbin/php-fpm /sbin/php-fpm.backup
Source: https://talk.plesk.com/threads/set-default-php-version-for-command-line.345940/