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.

[bjornad]

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:

$ apt-get update && apt-get install 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-apt-repository ppa:mapnik/boost

Add the HHVM Ubuntu repository:

$ curl http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add -
$ add-apt-repository 'http://dl.hhvm.com/ubuntu'

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):

$ sed -i -e 's|deb-src http://dl.hhvm.com/ubuntu|#deb-src http://dl.hhvm.com/ubuntu|g' /etc/apt/sources.list

Now install HHVM:

$ apt-get update && apt-get install hhvm

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

$ update-rc.d hhvm defaults

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:

$ echo "RUN_AS_USER=\"websiteuser\"" >> /etc/default/hhvm
$ echo "PIDFILE=\"/home/websiteuser/.hhvm.pid\"" >> /etc/default/hhvm
$ service hhvm restart

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:

location ~ \.php$ {

… which can be replaced with:

include hhvm.conf;

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:

$ /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60