If you need to use between different PHP versions for your website or project, this guide will show you how to easily change the PHP version using the cPanel Terminal. This is especially helpful for developers who want to test compatibility or meet specific software requirements.
Steps to Change the PHP Version in cPanel Terminal
1. Log in to cPanel
Start by logging into your cPanel account with your username and password.
2. Open the Terminal
Once you’re in the cPanel dashboard, use the search bar to find the “Terminal” tool. Click on the Terminal icon to open it.
3. Check the Current PHP Version
Before making any changes, you may want to check which PHP version is currently active. To do this, type the following command in the Terminal:
php -v
This will show the PHP version that’s currently in use.
4. Change the PHP Version
To switch to a different PHP version, use the appropriate command depending on the version you need. Below are the commands for common PHP versions:
- For PHP 8.2:
/opt/cpanel/ea-php82/root/usr/bin/php /opt/cpanel/composer/bin/composer
- For PHP 8.1:Replace “ea-php82” with “ea-php81”:
/opt/cpanel/ea-php81/root/usr/bin/php /opt/cpanel/composer/bin/composer
- For other versions:
Simply replace “ea-php82” with the version you need, like “ea-php80” for PHP 8.0 or “ea-php74” for PHP 7.4.
Ensure that the output shows the correct version.
Why Should You Change PHP Versions?
There are several reasons to change your PHP version:
- Compatibility Testing: Check how your website or application works with different PHP versions.
- Software Requirements: Some plugins or software may require specific PHP versions to function correctly.
- New Features: Newer PHP versions often come with improved performance and security features.
Switching PHP versions is simple and can help ensure your website or project runs smoothly with the required tools and frameworks.