Resolve Website Issues After PHP upgrade 2017 [SOLVED]

Site Issues after upgrading PHP

After upgrading to PHP 7, you may notice that your site is having issues. For example on a WordPress site, certain plugins will be disabled and you will see messages stating that certain PHP modules are missing.

eg.

  • requires the function mb_detect_encoding to import and export CSV files
  • …currently has no PHP cURL library activated
  • AWS plugin is disabled
  • mb_detect_encoding not enabled
  • SOAP module not enabled
  • ZipArchive Library is missing or disabled
  • PHP Fatal error: Cannot redeclare class wfWAFWordPressRequest

The admin.php?page=wc-status page will tell you that certain PHP modules are missing as well.

After installing these modules on your server and confirming that they are working, your site may still produce these errors.

From the command line, the following command will output what version of PHP is being used.

And this will tell you what php.ini file is being looked at:

But, this can fool you! It shows you the php.ini file that is used by the PHP CLI, NOT the Apache web server serving your site!

How to see what version of PHP Apache is using

Is Apache still using the old php.ini file?

To see, output the php.ini file as Apache “sees” it by creating a file with in the root of your website and checking what version is being used.

WARNING: Give this file an obscure name. Do not name it phpinf.php. We do not want to give malicious coders any information about our system, do we?
REMOVE THIS FILE as soon as you are done with it as it is a security risk to have it there.

For this article, I am using an example of replacing PHP 5.6 with PHP 7.1 on an Ubuntu 14 server.

If you have installed PHP 7.1

If Apache is still looking at PHP5 (or whatever older version you had), it is likely that the Apache module for the upgraded PHP version is not installed.

One way to check for this is to take a look at the list of Apache modules.
On the command line, one cal list the enabled modules filtered for php modules like this:

If your output lists your old PHP version, then Apache needs the new PHP module installed and enabled.

Tell Apache to use the right PHP Version

You will first need to disable the old PHP module. Then install the Apache module for the new PHP version. If you have not yet installed the new PHP version, this can be done all on one line like this:

Here are the commands:

Leave a Reply

Your email address will not be published. Required fields are marked *