1. Code
  2. WordPress

Using HHVM With WordPress


Over the past few months HHVM has taken the PHP community by storm. Since WordPress 3.9 was released, HHVM is now 100% compatible with WordPress.

Unfortunately, HHVM is not quite ready for use in production in self-hosted environments. In my experience, HHVM crashes about once per day, which makes it not viable for a site where high availability is important. Recently, WP Engine has released project Mercury which seamlessly allows HHVM to gracefully fail by falling back to PHP 5.5 when it fails.

In this article, we're going to install HHVM on an Ubuntu server running the latest LTS release, 14.04. This can be accomplished either by using a visualization program like VirtualBox (free) with a downloaded Ubuntu ISO file, or by using a cloud hosting service. DigitalOcean offers cloud servers for $5 a month, which is what I’ll be using in this tutorial.

The first thing you should do is update all packages and dependencies:

$ sudo apt-get update && sudo apt-get upgrade

Install MySQL

Now you need to install MySQL, the database that powers WordPress.

$ sudo apt-get install mysql-server

You should set a root MySQL password for obvious security reasons. If you are extra security conscious you should also run $ mysql_secure_installation and follow the necessary steps to lock down your server.

Install Nginx

The next thing you need to do is set up a webserver. I prefer to use Nginx because it is lightweight, versatile, and easy to configure.

$ sudo apt-get install nginx

Install HHVM

Now install HHVM. It isn't as straightforward as installing other packages because it is not available on the Ubuntu repository. Instead we have to download it from HHVM itself, along with a few dependencies.

Now that we have installed HHVM, we need to run an install script that will install the HHVM module for Nginx.

sudo /usr/share/hhvm/

Now restart HHVM and Nginx.

 sudo /etc/init.d/hhvm restart

sudo /etc/init.d/nginx restart

Set Up the Website

The next thing we need to do is set up a virtual host for our website. Typically you would create a new virtual host for each website on a server, but since we're testing (and for simplicity's sake) we're just going to overwrite the content of /etc/nginx/sites-available/default with a simple file below:

Note: you need root permissions to edit this file.

Now we can set up WordPress:

  1. Reload your updated nginx configuration: $ sudo service nginx reload.
  2. Now create a web root directory: $ sudo mkdir /var/www.
  3. Download WordPress:  $ sudo wget /var/www/.
  4. Extract WordPress: $ sudo tar xvf /var/www/latest.tar.gz.
  5. Move WordPress files to web root: $ sudo mv /var/www/wordpress/* /var/www/.
  6. Clean up: $ sudo rm -rf /var/www/wordpress /var/www/latest.tar.gz.
  7. Set permissions: $ sudo chmod -R 775 /var/www.
  8. Set groups: $ sudo chown -R www-data.www-data /var/www.

Set Up the WordPress Database

Log in to MySQL $ mysql -u root -p. Now run the following commands:

Now you can go to your server's IP address and follow the famous five-minute install. 


Congratulations! You now have your very own WordPress site running on cutting edge technology. Here are my speeds running default WordPress using HHVM, following the instructions above:

Speed results for website using HHVM

How fast is your site loading?

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.