Changing the CyberPanel PHP CLI Version

Changing the CyberPanel PHP CLI Version

Why do you need to change the CyberPanel PHP CLI version?

When installing CyberPanel, it runs code by default to set the global PHP CLI to use PHP 7.4 with the following code

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

So, even if you have changed the PHP version for your website, the PHP CLI version used will remain PHP 7.4. This might prevent you from running certain commands that require a different PHP version, such as PHP 8.1.

How to Change the CyberPanel PHP CLI Version?

Even though it is set to default to PHP 7.4, that does not mean you cannot change the PHP CLI version.

However, before changing the PHP CLI version, you might want to know where the PHP versions are stored and used.

The PHP versions that can be used in CyberPanel are stored in /usr/local/lsws/lsphpXX, where xx is the PHP version.

For example, for PHP 7.4, the location is /usr/local/lsws/lsphp74.

Okay, now that you know where the PHP binary is stored, you can change the CyberPanel PHP CLI version by following these steps

1. SSH Login

To log in via SSH, you can use Terminal, CMD, or an SSH application like PuTTY.

Cara Mengubah Versi PHP CLI Cyberpanel - 1

If you are using Terminal or CMD to log in as root, for example to a server with an IP 192.168.1.1 and port 1999 (default SSH uses port 22), you can use the following command

ssh [email protected] -p 1999

After successfully logging in via SSH as root to your CyberPanel server, you can update the PHP Symlink to use the PHP version you want.

Use the following command according to the PHP CLI version you intend to use

PHP 7.1

ln -s /usr/bin/php /usr/local/lsws/lsphp71/bin/php -f

PHP 7.2

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

PHP 7.3

ln -s /usr/bin/php /usr/local/lsws/lsphp73/bin/php -f

PHP 7.4

ln -s /usr/bin/php /usr/local/lsws/lsphp74/bin/php -f

PHP 8.0

ln -s /usr/bin/php /usr/local/lsws/lsphp80/bin/php -f

PHP 8.1

ln -s /usr/bin/php /usr/local/lsws/lsphp81/bin/php -f

Why do you have to add -f to the command, while the official CyberPanel documentation does not use that code?

That code is used to force the symlink update. If you do not use it, you will receive an error message ln: failed to create symbolic link ‘/usr/local/lsws/lsphp81/bin/php’: File exists

Cara Mengubah Versi PHP CLI Cyberpanel - 2

3. Reboot Server

The final step to apply the changes is to reboot the server, either by using the command reboot in SSH, or by rebooting through the VPS management page provided by your server host.

After a successful reboot, you can check the PHP CLI version using the command php -v, and the PHP version will have changed from 7.4 to the version you selected

Cara Mengubah Versi PHP CLI Cyberpanel - 3

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...