Isrg KB
The Best Way to Gain Knowledge

Safest Way to Switch from PHP 5.x to PHP 7.x Without Breaking into Error 500 in WordPress

Switching from PHP Versions 5.4, 5.5 or 5.6 to PHP Version 7.0, 7.1 or 7.2 is easy when you are on a shared or Fully-Managed Hosting since most of configuration and stuffs are taken care by your hosting provider, but it maybe a headache when you are on a Private Virtual Server (VPS) or Dedicated Server where you are solely responsible for managing the entire server including the configuration.

I’ve been using PHP Version 5.6 on my server that uses cPanel/ WHM and is running on CentOS since its launch in 2014, but in 2018 I decided to take-down PHP 5.6 and setup 7 on my server, but at initially when I switched from PHP 6 to 7 I encountered with Error 500 Internal Server error and the reason was, the facts were not known so, I gone through entire documentation and discovered that some of the stuffs were missing and after fixing I was successfully able to deploy PHP 7 with Apache EasyApache4. Well, In this article we will learn to switch from PHP Version 5 to PHP Version 7 without getting into error 500 in WordPress.

Switching to PHP 7 with WordPress using WHM

Web Host Manager (cPanel WHM) one of the GUI based easy tool to manage server, extensions, plugins and also to keep the server safe and secure from any kind of brute force attacks.

Simply run yum install ea-php70 (for CentOS) from Putty or Console to download and install PHP 7 or you can chose any of the PHP versions from below:

  1. ea-php70
  2. ea-php71
  3. ea-php72
Important: Don’t forget to run the update command which is yum update in CentOS

If you are running uBuntu or any other Linux Based Operating System you can run apt-get install ea-php70 from Console or Putty to install PHP 7 or the desired PHP version.

Once you have successfully installed the desired PHP version simply login into WHM cPanel and from the left sidebar Navigation select Software –> EasyApache 4 –> Select the Currently Installed Packages and click on the Customize button.

On the EasyApache 4 Customisation page click on PHP Extension in the left side of the page and enable php70-php-mysqlnd and click on Next button, on the next page simply click on the Provision button to save the settings and the configurations.

If php70-php-mysqlnd is not available in the list simply run yum install php70-php-mysqlnd from the Console / Putty and follow back the above mentioned steps.

Once you have Provisioned the EasyApache 4, go back to the WHM cPanel and in the left sidebar navigation click on Software –> MultiPHP Manager and under the PHP Versions tab you can chose the default System PHP Version for all the domains and accounts hosted on the server. Alternative to this you can enable PHP 7 or the desired PHP version from Set PHP Version per Domain section given on the same page.

That’s all you’ve to do in order to fix the WordPress 500 Internal Server error caused after switching to PHP 7.0 or 7.1 or 7.2. PHP developer decided to discontinue with Mysql and use Mysqli where Mysql is not supported by WordPress with PHP 7 and the reason you are getting error 500. In addition to enabling php70-php-mysqlnd you may also have to enable cURL and other libraries which are disabled by default in PHP 7.