WordPress will make PHP 7.0 the minimum required version, upgrade your PHP version soon

This has just come to my attention today, the developer team at WordPress will be making changes to the minimum PHP versions required by the WordPress core in the upcoming months. This is tracked in the core discussion here, a news article from ZDNet also talks about this change here.

Starting with WordPress 5.1, a warning will be shown in the Admin area for websites running PHP 5.6 or lower.

However, by December 2019 the plan is to have PHP 7.0 to become the minimum required PHP version required to run a WordPress site.

Ideally you should update the PHP version on your server sooner, rather than later. It is really quite a painless procedure – I have added some steps below which may help.

Myself, I am running PHP 7.2 as this version is supported until 30th November 2020 as stated on the official PHP website. Also, I found a large speed improvement over the 5.6.x branch – There is a good post about some real-world tests on Kinsta’s website.

 

How to upgrade to PHP 7.2?

There are a few different ways depending on what hosting service you’re using.

Shared Hosting (also including Reseller Hosting)

If you’re using shared hosting, you’re more than likely have access to a control panel interface such as cPanel, if not you can ask your hosting provider to upgrade your PHP version on your behalf, and if they’re not able to maybe it’s time to switch to another host [affiliate link].

  1. Once you’re logged into your cPanel account, you should have a ‘MultiPHP Manager’ option:
  2.  Select this option, and then select the domains for the version you wish to change:
  3.  Now select the new PHP version from the dropdown menu, and click ‘Apply’:
  4.  That’s it! You can create a PHP Info file on your server to check the new version has been applied. More info on that here.

If these instructions don’t match your shared hosting setup, contact your provider and they will be able to help – not all shared hosting environments are the same, with options differing from provider to provider.

 

Self-Hosting/VPS/Dedicated servers

If you’re already self-hosting or have a VPS/Dedicated server, you should already be well-versed in setting-up and configuring your web-server stack.

I take no responsibility for the upgrade instructions below, and you should always take a backup of your system.

These instructions were test on an Ubuntu 18.04 system. To upgrade from PHP 5.6 running with Apache2 to PHP 7.2 follow these steps:

  1. Check for updates:
    sudo apt-get update
  2. Find all current PHP 5.6 modules. Make a note of these as you will need to re-enable/install these modules later:
    sudo apt-cache pkgnames | grep php5.6
  3. Disable PHP 5.6:
    sudo a2dismod php5.6
  4. Install PHP 7.2:
    sudo apt-get install php7.2
  5. Now enable PHP 7.2:
    sudo a2enmod php7.2
  6. Now restart Apache2:
    sudo service apache2 restart
  7. Based on the list of modules from PHP 5.6, install these for version 7.2. Your list may be different to mine, but these are my recommended modules:
    sudo apt-get install php7.2-xmlrpc php7.2-bz2 php7.2-cgi php7.2-cli php7.2-dba php7.2-dev php7.2-fpm php7.2-gd php7.2-gmp php7.2-opcache php7.2 php7.2-pspell php7.2-recode php7.2-common php7.2-bcmath php7.2-sqlite3 php7.2-tidy php7.2-json php7.2-mbstring php7.2-readline php7.2-xml php7.2-xsl php7.2-curl php7.2-zip php7.2-ldap php7.2-pgsql php7.2-imap libphp7.2-embed php7.2-intl php7.2-enchant php7.2-odbc php7.2-snmp php7.2-soap php7.2-sybase php7.2-phpdbg libapache2-mod-php7.2 php7.2-mysql php7.2-interbase
  8. Enable these modules (If not already enabled):
    sudo a2enmod rewrite
    sudo a2enmod ssl
  9. Install Mcrypt:
    sudo apt-get install mcrypt
  10. Now edit your PHP.ini file, I do this to adjust the ‘post_max_size’ and ‘upload_max_filesize’ values as the defaults are too low. You PHP.ini may be kept in a different location, so be sure to change this:
    post_max_size = 40M
    upload_max_filesize = 40M
  11. Now restart Apache2:
    sudo service apache2 restart
  12. One last step, option if you’re not using phpMyAdmin 4.6.6. There is currently a compatibility between phpMyAdmin 4.6.6 and PHP 7.2. As described in this StackOverflow post.

    Run this one-line code command to fix the issue with viewing tables:

    sudo sed -i "s/|\s*\((count(\$analyzed_sql_results\['select_expr'\]\)/| (\1)/g" /usr/share/phpmyadmin/libraries/sql.lib.php

    Now fix the issue that happens when exporting databases.

    sudo nano /usr/share/phpmyadmin/libraries/plugin_interface.lib.php

    And replace: if ($options != null && count($options) > 0) {

    With: if ($options != null && count((array)$options) > 0) {

    Now save and exit the file.

There are no comments, be the first. Use the form below to add your comment

Post a Comment