HHVM, or the HipHop Virtual Machine, is a virtual machine for PHP developed by Facebook to improve the performance of PHP applications. Unlike the regular PHP runtime, HHVM uses a just-in-time compiler to convert scripts into native machine code. As a result, third-party benchmarks have shown as much as a 3x load time reduction over PHP-FPM 5.4 for tasks like loading a regular Drupal website.
While very fast, HHVM is also still under development and may not run some software properly or may not support some necessary extensions. Proceed with caution. For a list of supported, integrated PHP extensions, follow this link.
Ubuntu
10.04 (lucid)
12.04 (precise)
14.04 (trusty)
Debian
8 (jessie)
7 (wheezy)
Mint
16 (Petra)
These are the distributions that Facebook and the HHVM maintainers will support, and the distributions that are still actively maintained for servers. While it is possible to install HHVM on an Ubuntu 14.10 server, doing so is not supported (at the time of writing) by HHVM and may result in bad things happening.
One of the distributions above.
Root access for configuration and installing packages.
Installing HHVM itself is quick and painless, involving not much more than configuring repositories and installing.
For Lucid (10.04) and Precise (12.04) users only: Both versions of Ubuntu require the addition of repositories. To streamline the process, we need to make sure that the add-apt-repository command is ready. If you are not using Lucid or precise, skip over this set of commands. Otherwise:
sudo apt-get update
sudo apt-get install python-software-propertiesFor Lucid (10.04) users only: HHVM has a few more dependencies that are not included in the base system or repositories.
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.8 g++-4.8 gcc-4.8-baseFor precise (12.04) users only: You’ll also need to add a repository to obtain the libraries needed to run HHVM.
sudo add-apt-repository ppa:mapnik/boostHHVM also requires installing a GPG key for its repository.
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -Once that’s done, we can add HHVM’s repository to the sources.list file.
echo deb http://dl.hhvm.com/ubuntu DISTRIBUTION_VERSION main | sudo tee /etc/apt/sources.list.d/hhvm.listMake sure to replace DISTRIBUTION_VERSION with your Ubuntu version’s codename: lucid, precise, or trusty.
Now we can install.
sudo apt-get update
sudo apt-get install hhvmAnd we’re done!
HHVM installation on Debian is similar to Ubuntu, but less fragmented across distributions. You’ll only need one set of commands for Jessie or Wheezy.
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
echo deb http://dl.hhvm.com/debian DISTRIBUTION_VERSION main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvmMake sure to replace DISTRIBUTION_VERSION on the second line with your Debian version’s codename, jessie or wheezy. HHVM should now be installed.
Mint's installation is also very similar to Debian's in that it’s simplified.
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
echo deb http://dl.hhvm.com/mint petra main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvmSince Petra is the only supported Mint distribution at the moment, that’s it!
With HHVM comes a nifty configuration script that automatically sets up a CGI handler for either server.
If you are using Nginx, make sure to edit your server’s configuration file (by default /etc/nginx/sites-available/default) to disable FastCGI processing. Look for a section like the following and make sure it either does not exist or is entirely commented out (by adding # to the beginning of each line in the section):
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_index index.php;
# include fastcgi_params;
#}If you are using Apache, there’s nothing specific for you to do.
After that, simply run the following script.
sudo /usr/share/hhvm/install_fastcgi.shApache or Nginx should automatically be configured and restarted, and HHVM should now be running on your server. To test it, you can either make a file like this:
<?php phpinfo();And look for “HipHop” or “HHVM,” or you can run a script like this:
<?php if(defined('HHVM_VERSION')) { echo 'HHVM works!'; }If “HHVM works!” appears, then you’re all set!