Running HHVM instead of PHP with Nginx on Ubuntu

Since version 3.9, WordPress have been 100% compatible with HHVM and I have begun replacing PHP with it on a few of my servers to experiment.

All my servers run Ubuntu LTS. Most of them still run 12.04, but some of them also run 14.04. I’ve tested installing HHVM on both, and the process is pretty much the same.

First of all, you should have Nginx up and running.

Second, we’ll make sure add-apt-repository is available, as it makes adding repositories a bit smoother. It is provided by the package python-software-properties:

If you are running Ubuntu 12.04, you will need a few libboost-* packages, and they are available from a PPA (you can skip this step if you’re running Ubuntu 14.04):

Add the HHVM Ubuntu repository:

If you’re on 12.04, the src repo will be added automatically, but it’s not available, so remove it (again, you can skip this step on 14.04):

Now install HHVM:

… and make sure HHVM starts when the system is booted:

Now, if you’re like me, you want your PHP scripts to run as some other user than the default www-data. Let’s say this user is websiteuser with the home directory /home/websiteuser. Replace with your own values accordingly:

During the installation a default Nginx config block should have been placed in /etc/nginx/hhvm.conf. Usually, you don’t have to edit this file, but it’s a good idea to take a look to get to know the contents. Just include this file wherever you you normally would have a PHP block, and remove the PHP block if you have one. It usually starts with the line:

… which can be replaced with:

If you had PHP installed, you can now remove it. You probably want to get rid of php5-fpm at least, to free up some RAM. If you remove PHP entirely, including php5-cli, you might want to use HHVM instead for command line scripts:

There are no comments

I love comments that bring new insights, shares ideas and experiences, and most of all: corrects my mistakes. For support questions, there are other fora, like Stack Overflow, Server Fault and the WordPress support forum.

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