AdminsForum

CyberPanel PHP & LSPHP Guides

Guide CyberPanel: Why php -v Shows a Different PHP Version Than Your Website

Started by JAY 0 replies 121 views
1JAY
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
#1
CyberPanel: Why php -v Shows a Different PHP Version Than Your Website (Tested)

You set your website to PHP 8.5 in CyberPanel, then run
Code:
php -v
over SSH and it says 8.3. Or Composer complains about the PHP version although the site runs fine. Nothing is broken: the
Code:
php
command in the terminal and the PHP your website uses are two separate things. We checked this on a CyberPanel 3.0.8 server (Ubuntu 24.04) and tested each way to run the right version.

What we saw
Our test site was set to PHP 8.5 in the panel. (Each site's version is shown under Websites → List Websites.)
cyberpanel list websites php version   
A test page on the site reported 8.5.12. In the terminal:
Code:
php -v PHP 8.3.36 (cli)
The reason is one link:
Code:
ls -la /usr/bin/php /usr/bin/php -> /usr/local/lsws/lsphp83/bin/php
The terminal's
Code:
php
is a fixed shortcut to one version (8.3 on our server). Changing a website's PHP in the panel doesn't touch it.

Every version has its own command
CyberPanel installs each PHP version in its own folder. See which ones you have:
Code:
ls -d /usr/local/lsws/lsphp*/bin/php
On our server that listed 8.1 to 8.5. To run a specific version, use its full path:
Code:
/usr/local/lsws/lsphp85/bin/php -v /usr/local/lsws/lsphp85/bin/php yourscript.php
The number is the version without the dot:
Code:
lsphp85
is PHP 8.5,
Code:
lsphp82
is 8.2.

Composer with the right PHP
Put the PHP path in front of Composer:
Code:
/usr/local/lsws/lsphp85/bin/php /usr/bin/composer install
We checked with
Code:
composer diagnose
: it reported PHP version 8.5.12 (/usr/local/lsws/lsphp85/bin/php).

WP-CLI with the right PHP
Same idea:
Code:
/usr/local/lsws/lsphp85/bin/php /usr/local/bin/wp --path=/home/yourdomain.com/public_html cli info
This reported PHP 8.5.12. One thing that did not work for us: the
Code:
WP_CLI_PHP=...
variable you'll find in many tutorials. With it set, WP-CLI still used 8.3 on our server. Use the full path instead.

Cron jobs
Cron jobs use the terminal's
Code:
php
too. If a cron job must run with the site's version, write the full path in the cron line:
Code:
/usr/local/lsws/lsphp85/bin/php /home/yourdomain.com/public_html/cron.php
(See our cron jobs guide in the Websites section for where to add it.)

Change the default for the whole terminal
If all your sites use the same version, you can point the shortcut at it:
Code:
ln -sfn /usr/local/lsws/lsphp85/bin/php /usr/bin/php php -v
We tested it:
Code:
php -v
then said 8.5.12, and plain
Code:
wp
used 8.5.12 as well. To go back, run the same command with
Code:
lsphp83
. We put ours back afterwards, because we can't say whether a CyberPanel upgrade resets this link or expects a certain version there. If you change it, check
Code:
php -v
again after panel upgrades.

Good to know
  • Extensions are per version. An extension you installed for 8.3 isn't there in 8.5. Check with
    Code:
    /usr/local/lsws/lsphp85/bin/php -m
    . (See our PHP extensions guide in this section.)
  • Settings can differ too. Each version has its own php.ini, so memory limits in the terminal aren't always the ones your site has.
  • A warning on old versions. Running PHP 8.1 in the terminal printed Unable to load dynamic library 'timezonedb.so' on our server. It still worked. The warning comes from an extension line in that version's config.

Questions? Reply below with the output of
Code:
php -v
and
Code:
ls -la /usr/bin/php
.
Reply

Messages In This Thread
CyberPanel: Why php -v Shows a Different PHP Version Than Your Website - by JAY - 11-14-2026, 05:52 PM
Possibly Related Threads…matched by title
Replies:0Views:101
Replies:0Views:305
Replies:0Views:212
Replies:0Views:223

Users browsing this thread: 1 Guest(s)
Forum Jump: