Default PHP Installation in CyberPanel
CyberPanel installs LiteSpeed PHP from LiteSpeed repositories. The installation directory for each PHP version is:
/usr/local/lsws/lsphpXX
Replace XX with the version number.
The PHP CLI binary path for each PHP version is:
/usr/local/lsws/lsphpXX/bin/php
For example, PHP 7.4 is located at:
/usr/local/lsws/lsphp74/bin/php
Check the Current PHP CLI Version
To check which PHP version is currently used for CLI, run:
php -v
Change the Default PHP CLI Version
CyberPanel sets the global PHP CLI version by creating a symbolic link at `/usr/bin/php`.
To change the default CLI PHP version, use the following command:
Set PHP 8.2 as Default CLI Version
ln -sfn /usr/local/lsws/lsphp82/bin/php /usr/bin/php
Set PHP 8.1 as Default CLI Version
ln -sfn /usr/local/lsws/lsphp81/bin/php /usr/bin/php
Set PHP 7.4 as Default CLI Version
ln -sfn /usr/local/lsws/lsphp74/bin/php /usr/bin/php
After running the command, verify the change by checking the PHP version:
php -v
Use a Specific PHP Version in Cron Jobs
Instead of changing the global PHP CLI version, you can specify the direct path to the PHP binary in your cron job.
For example, if your application requires PHP 8.1, use:
/usr/local/lsws/lsphp81/bin/php /path/to/your/script.php
This ensures that the correct PHP version is used only for that specific cron job.
Summary
✅ Check current CLI PHP version: php -v
✅ Change default PHP CLI version: Use ln -sfn to update /usr/bin/php
✅ Use a specific PHP version in cron jobs: Directly call the required PHP binary
This method ensures compatibility with applications requiring a specific PHP version on CyberPanel. 🚀