How to Change the Default PHP Version To 7.4, 8.0, 8.1, 8.2 in CyberPanel

How to Change the Default PHP Version in CyberPanel
CyberPanel uses OpenLiteSpeed as its web server, and by default, it assigns a specific PHP version. However, you may need to change the default PHP version for your server to match your application requirements. This guide will show you how to change CyberPanel’s default PHP version for every available PHP version.
📌 Step 1: Check Installed PHP Versions
Before changing the default PHP version, you need to check which PHP versions are installed on your system.
ls /usr/local/lsws
This will list all installed PHP versions, such as:
lsphp74 lsphp80 lsphp81 lsphp82
These indicate PHP 7.4, PHP 8.0, PHP 8.1, and PHP 8.2 are installed.
📌 Step 2: Change the Default PHP Version
To change the default PHP version in CyberPanel, use the following command format:
ln -sfn /usr/local/lsws/lsphpXX/bin/php /usr/bin/php
Replace XX
with the PHP version you want to set as default. Below are the commands for each version:
🔹 Set PHP 7.4 as Default
ln -sfn /usr/local/lsws/lsphp74/bin/php /usr/bin/php
🔹 Set PHP 8.0 as Default
ln -sfn /usr/local/lsws/lsphp80/bin/php /usr/bin/php
🔹 Set PHP 8.1 as Default
ln -sfn /usr/local/lsws/lsphp81/bin/php /usr/bin/php
🔹 Set PHP 8.2 as Default
ln -sfn /usr/local/lsws/lsphp82/bin/php /usr/bin/php
📌 Step 3: Verify the PHP Version
After changing the default PHP version, check if it has been updated successfully by running:
php -v
You should see output similar to:
PHP 8.2.0 (cli) (built: Dec 8 2022 14:35:50) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
📌 Step 4: Restart CyberPanel for Changes to Take Effect
Finally, restart CyberPanel and the web server using:
systemctl restart lscpd
systemctl restart lsws
✅ Conclusion
By following these steps, you can easily change the default PHP version in CyberPanel to match your project’s requirements. If a specific PHP version is not installed, you may need to install it manually before switching.