PHP Revolution: HHVM and WordPress 3.9

Updated on November 05, 2017

What is HHVM?

There’s this small(ish) site that a couple of people visit every single day and spend hours there, you might have heard about it: it’s called Facebook. It is written in PHP and about four years ago when it really took off, the computational power that was needed to serve all requests was just too much because of the inefficiencies of  PHP execution engines’ that were available at that time. So they came up with the idea that instead of keep buying more server boxes, maybe they could solve the problem on a software level and created a PHP to C++ compiler named HPHPc. The original PHP code was compiled into executable binaries (sometimes file sizes reaching as much as a gigabyte!) and it was run instead of being compiled to opcodes and interpreted.

This gave about six times the performance which, to this day, is still a huge deal and one of the reasons we’re eagerly watching the development of the technology – and have been waiting for the mainstream adoption of it. Six times faster may not sound much when talking about general computer stuff, but if you look at it the following way, it might help put it in perspective for you: instead of having to buy 600 server machines to power a web service you only need 100. That’s a lot of savings just because you changed the way you run the code!

However, as you can imagine, running and maintaining separate developer and debugger versions of HipHop (called HPHPi and HPHPd, respectively), plus distributing gigabytes of executables to each machine after just a couple of changes in the code (think bug fixes), would quickly become tiresome and challenging.

This is why in 2013 Facebook decided to deprecate HPHPc but recycle the code and the experiences they gained from having it in production for at least three years and launched the HipHop Virtual Machine (HHVM). This engine converts PHP to bytecode which in turn is further converted into 64bit machine code at runtime by a just-in-time (JIT) compiler. The results? For some time now HHVM has outperformed the original HPHPc, in fact, Facebook’s production version is completely run on HHVM since Q1 2013. While benchmarks vary quite a bit (as always, they depend on a lot of factors), the results speak for themselves: 2 to 20 times performance increase when using HHVM compared to PHP-FPM.

HHVM and WordPress

As with all new software that’s set out to change the world, HHVM had quite a few problems running basically anything else other than the Facebook codes, which isn’t really a surprise, after all, it was written to do exactly that and just that!

If you tried to run WordPress with the help of HHVM either as a web server on its own (now a deprecated feature) or as a FastCGI replacement, you could have run into various problems, like having to manually edit wp-db.php as HHVM doesn’t support case-insensitive constants.

In the past year the HHVM open source project has really started to grow up and a result of countless of hours of work by its and WordPress’s developers, starting with version 3.9 of WordPress*, it will be running all WP codes without any hiccups (fingers crossed). This is the time to make the change to HHVM!

* If you didn’t follow 3.9’s development: Improve HHVM compatibility by eliminating some of our last remaining create_function() calls and making OBJECT a case sensitive constant. [27373] [27374] [27465] #14424 [27377] #27231

I’m pretty sure DevOps is an antidepressant, so why should I care?

You might not be managing your own server, but rest assured your hosting company is running some kind of a PHP processor. If it’s not HHVM or if the company is not planning to change it anytime soon, then your site’s performance will suffer. You surely don’t want that, as a one second additional page load time results in 7% decrease in conversion rates. If your site could be loaded in 1.5 seconds and you could maximize profits by not doing anything (well, except using a great hosting company cough Kinsta! :) ) you could be missing out on 7 to 21% of revenue. Can you afford to do that?

Okay you got my attention, where do I start?

By signing up for a Kinsta account and letting us know that you’d like to be HHVM’d! :) Right now I don’t know about any competitors who are offering HHVM. If you are a hosting company and have HHVM, please let us know in the comments and I’ll include you in this article! Yes, we do link to competitors. :)

If you have your own server, however, you’ll have to install it from a pre-built package or compile it yourself and set it up.

Installing or Compiling HHVM on Ubuntu

Ubuntu 14.04

wget -O - | sudo apt-key add -
echo deb trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm

If you are getting segfaults

sudo apt-get install hhvm-dbg

Living on the edge (rebuilt everyday, unstable)

sudo apt-get install hhvm-nightly

Segfaults in the nightly

sudo apt-get install hhvm-nightly-dbg

Compile on Ubuntu 14.04

You must be running a 64-bit OS to compile & install HHVM.

sudo apt-get install autoconf automake binutils-dev build-essential cmake g++ git \
  libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev \
  libboost-system-dev libboost-thread-dev libbz2-dev libc-client-dev libldap2-dev \
  libc-client2007e-dev libcap-dev libcurl4-openssl-dev libdwarf-dev libelf-dev \
  libexpat-dev libgd2-xpm-dev libgoogle-glog-dev libgoogle-perftools-dev libicu-dev \
  libjemalloc-dev libmcrypt-dev libmemcached-dev libmysqlclient-dev libncurses-dev \
  libonig-dev libpcre3-dev libreadline-dev libtbb-dev libtool libxml2-dev zlib1g-dev \
  libevent-dev libmagickwand-dev libinotifytools0-dev libiconv-hook-dev libedit-dev \
  libiberty-dev libxslt1-dev ocaml-native-compilers \

Download the latest source code:

git clone git://
cd hhvm
git submodule update --init --recursive
cd ..

Compile and install:

cd hhvm
cmake .
sudo make install

Installation Links for Other Systems

Using HHVM with Nginx

Add the following options to your Nginx virtual hosts file:

location ~ \.(hh|php)$ {
    fastcgi_keep_conn on;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;

For a more complete guide on how to install HHVM, Nginx and Laravel (yes, that can be exchanged for WordPress, just disregard the Laravel parts) read this great tutorial on Fideloper!

Update 21, Apr 2014:

A couple of tests with HHVM :)

(to be updated with more!)

What do you guys think, is HHVM ready for everyday usage with WordPress? Will it revolutionize PHP? Please share in the comment sections below!

This article was written by Mark Gavalda
Mark has many years of experience leading teams in the fields of marketing, web design and development. As a dev guy he used his WP expertise to collect the know-hows of creating a reliable and customer friendly hosting company to satisfy the increasing demand of clients. He is an urban cyclist and autodidact who never stops learning new skills.

Hand-picked related articles

  1. Gravatar for this comment's author
    greglgomez April 15, 2014 at 9:58 pm

    Sounds real interesting Mark!
    People are barely coming round to nginx and you guys are steaming ahead towards HHVM!
    Definitely carving your own slice of the market with vision like that. =)

    1. Gravatar for this comment's author
      Mark Gavalda April 15, 2014 at 10:06 pm

      Thanks Greg! I love living on the bleeding edge :), and I was waiting for a long time for HHVM and WordPress to get fully compatible. And thanks for confirming my speculation that there’s definitely business for a hosting company who doesn’t work with 5 years old technology! ;)

      1. Gravatar for this comment's author
        greglgomez April 16, 2014 at 10:44 am

        I’ve been having a look at your platform, and I have a questions for you about another Nginx host I’ve come across.
        Now disregard the prices, I’m not really drawing up that sort of comparison, because they aren’t a managed host anyway..
        But they have an interesting approach that I haven’t seen used elsewhere, their tiers are limited by number of requests instead of page views or bandwidth..

        So my question is, what led you to choose bandwidth over pageviews or any other metric for that matter?

        1. Gravatar for this comment's author
          Mark Gavalda April 17, 2014 at 10:21 pm

          Sorry for the delay! Well, everyone has to come up with a couple of limits in order to be able to price packages, that can be number of visitors, pageviews, requests, etc. they’re in the same “category” though. Our price structure follows the logical rules (at least to me) of not measuring the number of visitors / pageviews because that simply doesn’t make sense to me: a pageview will only require X amount of computational power, which your setup either can or cannot handle, but bandwidth costs “a lot” (that’s subjective of course) for all hosting providers, and because MaxCDN is included in all our packages, we can tell exactly how many gigabytes a package can transfer before it becomes unprofitable for us. Of course there are situations when all these will play their role in the final pricing, but that’s not the “norm”, and we’ll always talk about custom projects and give a custom tailored quote in those cases.

  2. Gravatar for this comment's author
    tudoutou April 18, 2014 at 11:21 am

    I’m a wordpress freelancer, provide HHVM or nginx hosting to my clients, I also use cdn,varnish, memcache, reddit to make their site faster, happy to know there comes more wordpress specialized hosting. I do all stuff manually to meet clients’ need, not a competitor :)

    1. Gravatar for this comment's author
      tudoutou April 18, 2014 at 6:16 pm

      BTW, is still showing no related content in

      1. Gravatar for this comment's author
        Mark Gavalda April 18, 2014 at 6:39 pm

        I’m not sure I understand what you mean?

        1. Gravatar for this comment's author
          tudoutou April 19, 2014 at 3:04 am

          You did not set a default virtual host, so is showing content of 9 hours ago, is not redirecting to, it shows content of

          1. Gravatar for this comment's author
            Mark Gavalda April 19, 2014 at 3:06 pm

            I’m not sure what’s with that, it’s working on our end. Maybe a glitch in the config file when reloading earlier, or a bad cache. Anyways it seems fine! Thanks though!

  3. Gravatar for this comment's author
    Mark Jaquith April 21, 2014 at 3:31 am

    I’ve been playing with HHVM and WordPress 3.9 today. Its performance is really impressive. But I don’t think it’s ready for production use quite yet. For instance, WordPress cookies aren’t set properly when using HHVM (you’ll be logged in the backend, but not on the front of your site). I opened a ticket for that.

    But I expect that it’ll be ready for tentative production use real soon. The great thing is that it’s super simple to switch between PHP-FPM and HHVM… just a one-line change in your Nginx config.

    1. Gravatar for this comment's author
      Mark Gavalda April 21, 2014 at 5:47 pm

      Thanks, Mark! Yep, I think there’s great potential in HHVM, it just has to “grow up” and receive a bit more exposure :) And exactly because of that wise decision by the HHVM team to go the FastCGI way, we can offer the choice for our clients to choose between HHVM and PHP-FPM! If something doesn’t work as it should with HHVM (I haven’t noticed the front-end cookie bug you mentioned, thanks for calling our (and the creators’) attention to that!) then they can just switch back to PHP-FPM. To be honest for the vast majority of WP based sites FPM is more than enough, especially with a good caching system in place. It’s the high traffic sites and the modern web apps built on WP that should do tests with HHVM and make the switch as soon as possible!

  4. Gravatar for this comment's author
    Mangap May 4, 2014 at 11:54 pm

    After wordpress I think better hhvm help opencart 2.0
    So it can use hhvm. Opencart 1.x is slow, and many people did not like the slow problem.

    Beside that please try to make many hosting support hhvm by default such as: host monster, host Gator, dream host, racks pace, blue host, godaddy and others.

    1. Gravatar for this comment's author
      David Martínez Moreno July 27, 2014 at 4:57 pm

      Hey, Mangap. Please report any issue with Opencart 2 in our issue tracker in Github, as we are prioritizing compatibility issues like that one, to be able to run the usual bundles in the industry (like WP+OC 2) purely on HHVM.

      1. Gravatar for this comment's author
        Mark Gavalda July 29, 2014 at 9:34 am

        Thanks for stopping by David! It’s awesome that you guys are doing the HHVM optimization and it’s nice to see that you reach out to those who need help! Bests, Mark

        1. Gravatar for this comment's author
          David Martínez Moreno July 31, 2014 at 9:04 am

          You are very welcome! :-)

  5. Gravatar for this comment's author
    Chuck Reynolds May 13, 2014 at 10:35 pm

    Been using HHVM for a bit now w/ WordPress… built a custom install script for HHVM + Nginx too..
    Wondering why you went with 13.10? not lts? Anyways… 14.04 is out and solid. script works with it too.

    1. Gravatar for this comment's author
      Mark Gavalda May 13, 2014 at 10:59 pm

      That’s a really nice script Chuck! Thanks for sharing! Starred. :)
      Yep, I’ll have to update the guide to 14.04 now of course! :)

      So, what is your experience with HHVM and WP so far?

      1. Gravatar for this comment's author
        Chuck Reynolds May 13, 2014 at 11:00 pm

        right on thanks. So far – LOVE it. We did try hhvm on a very large site we run and had to switch back to php5_fpm due to some older php dependancies with a recipe plugin and things but overall – loving HHVM :)

  6. Gravatar for this comment's author
    Moscato-Moe August 30, 2014 at 5:11 pm

    Your stats about how much faster hhvm is is a bit of a lie.

    Hhvm is a bit faster than php-fpm with the opcache enabled

  7. Gravatar for this comment's author
    Kingsley Felix October 3, 2015 at 12:47 am

    I have everything installed but its blank on firefox

  8. Gravatar for this comment's author
    Antonio Rossi January 12, 2016 at 5:14 am

    dumb question, wordpress can run on HHVM if the server support it, but all plug in developed for wordpress, too?

    1. Gravatar for this comment's author
      tomzur January 12, 2016 at 6:01 am

      Unfortunately not because not all plugins all compatible with HHVM.

      1. Gravatar for this comment's author
        Antonio Rossi January 13, 2016 at 5:02 am

        too bad! :(

Leave a Reply to Mark Gavalda Cancel reply

Use WordPress?

Join 20,000+ others who get our FREE weekly newsletter with WordPress tips on how to drive more traffic and revenue to your business!

You have Successfully Subscribed!

Send this to a friend