Before proceeding with the changes, first of all, we've to check the current CLI PHP version, so run:
The output may be like this:
[root@elnath]# php -v
PHP 7.1.33 (cli) (built: Nov 22 2019 11:40:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies
As we can see, PHP version 7.1 is set as the CLI PHP. If you have certain needs and PHP 7.1 does not work for certain applications you can run the following command to update the default PHP on CLI:
ln -s /usr/bin/php /usr/local/lsws/lsphp81/bin/php
ln -s /usr/bin/php /usr/local/lsws/lsphp80/bin/php
ln -s /usr/bin/php /usr/local/lsws/lsphp74/bin/php
ln -s /usr/bin/php /usr/local/lsws/lsphp73/bin/php
ln -s /usr/bin/php /usr/local/lsws/lsphp72/bin/php
Please run any of those command lines as per your needs.
How to use specific PHP Version in your Cron Jobs?
Some applications require you to set cron jobs and they require PHP CLI executable. Now rather than changing the default global PHP binary version, you can use a direct path to that CLI.
For example, if an application requires that its script should be running through PHP 8.1, you can use the direct path for its binary rather than updating a global binary, such as:
/usr/local/lsws/lsphp81/bin/php <your command goes here>