How to change CLI PHP Version on CyberPanel

Before proceeding with the changes, first of all, we've to check the current CLI PHP version, so run:

php -v

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
[root@elnath]#

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>
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to restrict direct root access in Linux

We can do it just in two steps. Step One: At first we will create new root user as follows (for...

How to extract .tar.gz files in Linux/UNIX OS

A tarball is a group of files that are bundled together using the tar command. Use the...

How to add welcome message when SSH start?

You need to change the contents of /etc/motd. Unfortunately, by default, /etc/motd is a link to...

How to change root password when SSH logged in

Run the following command: passwd Now type your new passwordOnce done, retype new passwordDone!...

How to install Pinguzo on any Linux/UNIX OS

Login to Pinguzo panel using Softaculous account or create an account of Pinguzo To add new...