How do I change PHP CLI version?

#1
I am running OLS with CyberPanel. My question is related to OLS, so I am hoping someone here can assist.

I am running into issues when use PHP CLI (PHP on the command line).
I have install a website application that needs at least PHP 7.3 (I've got it on 7.4). It is a Composer project.

I need to be able to run Composer commands with at least PHP 7.3. But the server reports PHP 7.1.33 (when I do `php -v`). And when I do `whereis php` I see it's using PHP 7.2 (`/usr/bin/php /usr/bin/php7.2 /usr/lib/php /etc/php /usr/share/php /usr/share/php7.2-common /usr/share/php7.2-xml ... etc.`)

This creates a PHP dependency error when I run Composer commands, such as `composer install` or `php artisan` commands.

I have two question:

1) The most important one: How can I run PHP 7.3 or 7.4 on the command line on OLS server?

2) How can I change the default PHP used by LSWS?

Thank you very much for your assistance.

Jonathan
 

Pong

Administrator
#2
This is more your system and PHP related, nothing to do with OLS settings. There are several ways:

1. You can specify which php to use for composer
normally Cyberpanel will install all phps under /usr/local/lsws/lsphpxx/bin/php,
You can specify the php path become composer command like:
https://stackoverflow.com/questions/32750250/tell-composer-to-use-different-php-version

2. your php cli will normally use your system default php at default location.
"which php" should tell your which one it uses. You can backup that file to php.old, and create a symbolic link pointing to the php binary you want to use, such as /usr/local/lsws/lsphp73/bin/php or /usr/local/lsws/lsphp74/bin/php
 
Top