Most of the cPanel hosting providers offer a lot of features including the ability to run multiple versions of PHP on the same shared hosting. There are times when you want to run your application on a specific PHP version due to compatibility or any other reason.
I have been working with cPanel control panel for a long time. One of the issues I encountered lately was that I was unable to change PHP version on my cPanel hosting no matter what I did. The PHP version would get changed but would revert once I refreshed the cPanel page.
This article discusses exactly how I fixed this issue.
Let’s first take a look at how to change PHP version on cPanel. This is a standard practice of all hosts providing cPanel hosting including GoDaddy, Hostgator, a2hosting etc.
Changing the PHP version on cPanel
- Login to your cPanel account.
- Go to the Software section and click on “Select PHP Version“.
- The next page will show the current PHP version. You can see the PHP versions currently installed on your system in the drop-down list.
- To select a different PHP version, select the appropriate version from the drop-down list and press Set as current button.
This should change the PHP version immediately. There will be no downtime.
To confirm that your changes have taken effect, create a PHP page in the root directory of your hosting with the following code:
<? phpinfo(); ?>
Now open the page in a browser and you will get the information about your PHP configuration. For example, if I created a page called checking-php-config.php on itechtics.com, I would open it as https://www.itechtics.com/checking-php-config.php.
Once confirmed, please delete this page as showing your configuration publicly is risky.
Fix PHP selector not changing PHP version in cPanel
As discussed above, changing the PHP version is fairly simple but there are times when PHP selector will not change the PHP version in cPanel no matter what you do.
My site was running on the older version of PHP i.e., PHP 5.4 which became almost obsolete. Most of the new WordPress themes and plugins now require the newer versions of PHP. So I decided to upgrade PHP to 7.0 to be on the safer side although 7.3 is also available.
Since I was on A2Hosting, I was using cPanel and used the same steps listed above to change the PHP version. But it would not stick to the new value.
After researching for some time, I got the problem. cPanel hosts use .htaccess file for saving some PHP configurations. The issue was that I had changed the permissions of .htaccess file to be read-only for all users. So the system was also not allowed to write into the .htaccess file.
Once I changed the file permissions of .htaccess file to 644, and changed the PHP version afterward, the new change took effect immediately without reverting.
I hope this solution will help you fix your PHP version problems. Please share your experience with us in the comments below. We’ll be happy to help if your problem isn’t fixed yet.
- Fix: Laptop High Pitched Sound Problem Through The Speakers And Headphones
- How To Fix “No Audio Output Device is Installed” Error
- Fix Limited Or No Connectivity (No Internet Access) In Windows 10
- Fix: Unable To Download Any EXE File In Windows 10
- Fix: This Site Can’t Be Reached Error In Google Chrome