WordPress on PHP 7.1

Mattias Geniar, Thursday, March 9, 2017

Since I care about performance, features and security, I decided to upgrade my webservers' PHP version from 5.6 to the latest PHP 7.1.2. I run mostly WordPress websites, so what's the impact of such a PHP version upgrade on WordPress?

At the time of writing, PHP 5.6 is in extended support, meaning it'll still get security updates, but no more bugfixes. The PHP 7.x release is the only actively support PHP version, of which PHP 7.1 is the latest version.

Let's start with some benchmarks.

Performance improvements with WordPress on PHP 7.1

First, some numbers, before I go all graph on you.

I took a fairly big page on this blog (and a popular one, too) to run the ab benchmark against: Google’s QUIC protocol: moving the web from TCP to UDP.

The goal is to execute 300 requests as quickly as possible, 2 at a time (concurrency = 2).

$ ab -c 2 -n 300 https://ma.ttias.be/googles-quic-protocol-moving-web-tcp-udp/

For the sake of this test, I decided to disable the static HTML caching, I want the raw PHP performance.

The results (averaged out, as I did the test several times) -- lower is better;

  • PHP 5.6: 94.3 seconds
  • PHP 7.1: 74.5 seconds (22% faster)

For comparison, I also took a Laravel application I made called DNS Spy and did the same benchmark.

  • PHP 5.6: 40.1 seconds
  • PHP 7.1: 30.2 seconds (25% faster)

It's safe to assume PHP 7.1 is considerably faster than 5.6 with about 25% raw speed improvements. And this isn't counting the memory savings you get, because the 7.x branch is much more memory efficient than 5.6 (I just didn't accurately measure that to benchmark).

In a graph, the above timings are actually rather boring. In absolute numbers, it's the difference between an average response time of 350ms vs 250ms. Yes, it matters, but in a graph with spikes, it doesn't say much.

Things get more interesting when you look at pages that take more time to load, like the RSS feed in WordPress. This graph shows the RSS timings for the posts and the comments (2 separate requests).

In that graph, it's gone from an average response time of 610ms (for both feeds) to 280 ms. That's a 200% speed improvement over PHP 5.6!

WordPress compatibility on PHP 7.1

The million dollar question is, of course: what did I break by upgrading?

So far: nothing.

But I should point out, most of my blogs have a very limited set of plugins and are simple in both design and functionality.

WordPress itself will run, as a minimum requirement, on PHP 5.2.4 or higher. That's a bug, not a feature. That old PHP version should've been buried and forgotten a long time ago.

But there's an upside, too: because they still support PHP 5.2.x, they can't use any of the newer features of PHP 5.3 (namespacing), PHP 5.4 (anonymous functions), 5.5 (OPCache instead of APC), ... so WordPress core is really boring PHP. That boring PHP will run on pretty much any PHP version, including the 7.x branches.

Plugins are a different matter: popular plugins, like the Yoast SEO Plugin, will actively begin to encourage users to upgrade to a later PHP version. This is excellent news. It also means plugins are going to be your risk when upgrading PHP versions, as their supported PHP versions may vary.

Functionality testing on PHP 7.1

Limited, but this is what I tested (by writing this post) and what still works, flawlessly;

  • Post writing & editing
  • File uploads
  • GUI & text editor
  • Dashboard, WordPress statistics & widgets
  • Plugin updates & auto-updates

Seems to be the biggest pieces of functionality, to me.

PHP warnings & errors

This won't show in the GUI, but your error logs from PHP-FPM may start to show things like this;

$ tail -f php/error.log
[09-Mar-2017 20:41:54 UTC] PHP Warning:  A non-numeric value encountered in /var/www/vhosts/ma.ttias.be/htdocs/wp-content/plugins/.../Abstract.php on line 371
[09-Mar-2017 20:42:17 UTC] PHP Warning:  A non-numeric value encountered in /var/www/vhosts/ma.ttias.be/htdocs/wp-content/plugins/.../Abstract.php on line 371
[09-Mar-2017 20:43:54 UTC] PHP Warning:  A non-numeric value encountered in /var/www/vhosts/ma.ttias.be/htdocs/wp-content/plugins/.../Abstract.php on line 371

Since I have no interest in maintaining plugins and lack the time to learn how SVN works again to submit a PR or patch, I simply disabled warnings in PHP.

Conclusion: WordPress + PHP 7.1 = ❤️

For me, it just works. No quirks, faster performance & a fully supported PHP version.

What's stopping you from upgrading?

Hi! My name is Mattias Geniar. 👋 I'm an independent software developer ⌨️ & Linux sysadmin 👨‍💻, a general web geek & public speaker. Currently working on DNS Spy & Oh Dear! Follow me on Twitter as @mattiasgeniar 🐦.

🔥 If you're stuck with a technical problem, I'm available for hire to help you fix it!

Share this post

Did you like this post? Help me share it on social media! Thanks. 🤗

Have feedback?

New comments have been disabled on this blog, existing comments will remain as-is. Want to give feedback? Is there a mistake in the post?

Send me a tweet on @mattiasgeniar!


Muhammad Waqas Saturday, March 11, 2017 at 05:52 -

The reason why WP is reluctant to increase minimum requirement to PHP 7 is cheap shared hostings. And the “not tech savvy” users who don’t give a damn even about whats is WP made of. All they want is their site running somewhere. Clearly WP don’t want to lose that userbase.

Its similar to developers trying to add polyfills for IE 8.

Mattias Geniar Saturday, March 11, 2017 at 10:30 -

The reason why WP is reluctant to increase minimum requirement to PHP 7 is cheap shared hostings.

This is what always surprised me. We also offer shared hosting, and we actively push for newer PHP versions. It saves us CPU cycles and memory and we can run more shared hosting sites on a single server.

Even the hoster benefits, perhaps most of all!

Peak Design Monday, March 13, 2017 at 13:48 -

Definitely worth a share! Thanks for this Mattias Geniar :-)

Dusan Monday, March 13, 2017 at 18:11 -

Did you have installed and configured opcache on php 5.6?


Mattias Geniar Wednesday, March 15, 2017 at 14:09 -


Yes, the exact same PHP OPCache settings on 5.6 and 7.1;

$ cat opcache.ini
; Enable the opcache extension module
; Zend Extension

; Custom settings

These are similar to my recommended PHP OPCache settings.

Dusan Friday, March 17, 2017 at 03:40 -

Thanks for the response, Mattias.
( Asked because many benchmarks earlier were 5.6 without vs 7.0 with. And, I presumed that you made a test with it, I needed to ask. No relationship with WP though. :) Thanks again )

Fred Tuesday, July 18, 2017 at 03:11 -

Tried 7.1 – broke my WordPress sites.