TechWordPressSafest Way to Switch from PHP 5.x to PHP 7.x Without Breaking...

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 your hosting provider takes most of the configuration and stuff care. Still, it may be 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. Still, in 2018 I decided to take-down PHP 5.6 and setup 7 on my server. Yet, 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 went through entire documentation and discovered that some of the stuff was 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.

Run yum install ea-php70 (for CentOS) from Putty or Console to download and install PHP 7 or you can choose 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 click on the Provision button to save the settings and the configurations.

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

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 choose the default System PHP Version for all the domains and accounts hosted on the server. An 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 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 Mysql and use Mysqli where WordPress does not support Mysql 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.

Isrg Team
Isrg Team
Isrg Team is a member of Digital Pradesh News Networks, a collective of journalists, reporters, writers, editors, lawyers, advocates, professors, and scholars affiliated with the Digital Pradesh News Network.

Latest Updates