making bbPress (and WordPress) work better!

How to build HHVM 3.3 on CentOS 7.0

While building HHVM (HipHop Virtual Machine) for faster PHP on CentOS 6.x was pretty much a nightmare because almost none of third-party libraries are available from major repositories, the freshly released CentOS 7.0 solves most of this problem as it has far newer packages available from EPEL (because it has roots in more modern Fedora 19).

Note that unlike PHP/PHPNG, HHVM requires major resources to build. You may be used to making PHP in 15 minutes on a little old 256mb 1ghz box. You can forget that with HHVM which is a beast to compile. 1.5-2mb ram minimum and lots of cpu power required to keep it an hour or two (this is part of why PHP NG instead is so exciting because it will be so much easier to custom build).

I will assume you have CentOS 7.0 setup and know how to work in bash as root. Make sure you have either the default MariaDB or MySQL installed for the libraries.

You will first need to setup the EPEL repository in yum if you have not already:

yum install epel-release

Then you need the new 4.8 compiling tools (no more devtoolset needed like CentOS 6.x) cmake 2.8 as well as git if you don’t already have them installed.

yum install gcc gcc-c++ cmake git

Now you need a whole bunch of library dependencies, I think I found them all.

yum install psmisc binutils-devel boost-devel libmcrypt-devel libmemcached-devel jemalloc-devel libevent-devel sqlite-devel libxslt-devel libicu-devel tbb-devel libzip-devel bzip2-devel openldap-devel readline-devel  elfutils-libelf-devel libdwarf-devel libcap-devel libyaml-devel libedit-devel lz4-devel libvpx-devel unixODBC-devel libgmp-devel libpng-devel ImageMagick-devel curl-devel expat-devel openssl-devel

(typically installing the “devel” package will also install the parent package)

There are two packages left, google-glog and oniguruma, that CentOS 7.0 does not have in the main or EPEL repositories at this time unfortunately. However this is still far better than 6.x (which strangely does actually have oniguruma). So we have to build them ourselves.

cd /tmp
tar xvzf glog-0.3.3.tar.gz
cd glog-0.3.3
make install
cd /tmp
tar xvzf onig-5.9.5.tar.gz
cd onig-5.9.5 
make install

Now we are ready to pull down the huge source code for HHVM and all of its bundled third-party libraries.

I ran into a problem when trying to checkout the 3.2 branch where it is tied to an older libzip version 0.10 which does not work with 3.2 and requires 0.11 – this specific fix was still not applied to the 3.2 branch so unless that changes by the time you read this, you need to checkout the master instead.

cd /tmp
git clone -b master  hhvm  --recursive

(change -b master to -b HHVM-3.3 if they eventually fix 3.3 branch)

First do your configure and see if everything passes or if something was missed.

cd /tmp/hhvm

If it looks good, start the compile and go do something for an hour or two. If you have a multi-core machine with plenty of ram, you can try to accelerate make by telling it you have extra cores +1 (didn’t seem to work for me).

# make -j5  (where 5 is the number of cores you have plus one or x2)

When it is finished you can check the version and have it install the various libraries, binaries and header files.

./hphp/hhvm/hhvm --version
make install

Now you’ll need to setup hhvm’s server.hdf, an init.d script and update your fastcgi configuration in nginx or apache. Github is a great way to search for these items since this isn’t a packaged rpm and you have to DIY. You want newer things from hhvm 3.x instead of the old hhvm 2.x if possible.

If you want to try the new systemd way in CentOS 7 instead of init.d legacy way to start and stop hhvm, try this simple one to get started and copy it to

Description=HHVM HipHop Virtual Machine (FCGI)

ExecStart=/usr/local/bin/hhvm --config /etc/hhvm/server.hdf --user nobody --mode daemon -vServer.Type=fastcgi -vServer.Port=9000


If hhvm is running locally instead of a remote server, you might want to change from a tcp/ip socket to a unix socket by replacing

Last you’ll need to make a config file in /etc/hhvm/server.hdf, you can also try the new php.ini format style support but be aware they still have not made all settings accessable in the ini format.

Then you can do

systemctl enable hhvm
systemctl start hhvm
systemctl status hhvm

Don’t forget to

mkdir /etc/hhvm && mkdir /var/log/hhvm

(you will need to use /var/run/ for the pid and sock files unless you want to learn systemd-tmpfiles to create /var/run/hhvm/ automatically since /var/run/ is tmpfs in CentOS7)

You can try to find other hints, tips and tricks at the HHVM wiki on github.

I’ve also created a replacement for the missing phpinfo in hhvm here called hhvminfo

Hope that helps. Enjoy and let me know if I forgot anything.

4 responses

  1. Thanks for this great post.

    Some thoughts on make.

    According to it seems prudent to set j in make not to the number of processors, but in relation to the available RAM. For example, I use make -j20 to compile the Linux kernel, although I do not have 20 cores in my machine.

    July 19, 2014 at 2:14 pm

  2. Anonymous

    With a CentOS 7 Minimal install, in addition to wget, I had to install 3 additional packages to get make to run:


    P.S. No joke about the ~2 hour compile time.

    August 22, 2014 at 2:05 am

  3. Anonymous

    Thanks for the instructions. I had to add libpng-devel on a fresh CentOS 7 with Gnome installation.

    September 11, 2014 at 3:50 am

  4. Thanks for instructions.

    I had to install package: openssl-devel

    There is a issue with socket: hhvm (–user apache) always sets chmod 644 on /var/run/hhvm/hhvm.sock and nginx can’t write to it because it’s nginx user.

    And after stopping hhvm /var/run/hhvm/hhvm.sock still exists and next start fails.

    October 12, 2014 at 12:31 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 46 other followers