Change PHP CLI version

How do I change the default version of PHP used via console?

You can use this format to run your PHP scripts

/usr/local/lsws/lsphp74/bin/php /path/to/your.php

Replace lsphp74 with lsphp73 or any other version you need

Yes but how to use PHP 7.4 as default php alias?

Find the current location of PHP, assuming its in /usr/bin
Modify symbolic link
ln -s /usr/bin/php /usr/local/lsws/lsphp74/bin/php


I think Cyberpanel is a great panel but it lack a lot of documentation like this.

A lot of things are done like black magic

There’s always the fear that something set up by Cyberpanel will break…

@muttahir I’m interested in your symlink solution. Php -v in the console says my Php version is 7.1.33-3+bionic (cli) and I would like to change to 7.2.x and I see that /usr/local/lsws/lsphp72 does exist on the server, and I note above you say to modify symbolic link:

ln -s /usr/bin/php /usr/local/lsws/lsphp72/bin/php

Will there be an existing symlink pointing to the lsphp71 directory, and if so where might I find it please? Your help would be much appreciated (I have limited knowledge of symlinks).

I solved it using:
cp /usr/local/lsws/lsphp72/bin/php /usr/bin/

Type your comment> @NickW said:

I solved it using:
cp /usr/local/lsws/lsphp72/bin/php /usr/bin/

This worked for me also!

I think there should be a separate tab for PHP CLI version under

That would save a lot of people from having to go all SSH on it all the time.

Also wrote a complete guide regarding this → How to Change CLI PHP on CyberPanel? - Docs / 08 - Server - CyberPanel Community

1 Like

This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.