How to setup HHVM server on Ubuntu 14.04.

Mohammed Naser

Mohammed Naser

HipHop Virtual Machine was developed and open sourced by Facebook. It’s an open source virtual machine designed for executing programs written in Hack and PHP but it’s not a replacement for PHP. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance while maintaining the development flexibility that PHP provides. Facebook developed HHVM because the regular Zend+Apache combination isn’t as efficient to serve large applications built in PHP.

The advantage of HHVM is an increase in web request throughput and reduction in memory consumption compared to traditional PHP hosting. As a process virtual machine that provides the execution environment, HHVM has the ability to use live type information to produce more efficient native code, leading to higher web server throughput and lower latency.

Base Environment

In this tutorial we are going to setup HHVM under following set of resources on our cloud host.

  • Operating System: Ubuntu 14.04.2 LTS
  • Virtual CPUs: 4 cores
  • Memory (RAM): 1 GB
  • Disk Space: 40 GB

HVM doesn’t support 32 bit operating systems, so you must be running a 64-bit OS to compile & install HHVM.

System Update

Make sure that you have super user privileges to use sudo or root user and your system must be updated with latest updates otherwise we might get errors during the setup.

Let’s run the following commands to update and then upgrade your Ubuntu Operating system.

root@ubuntu-hhvm:~# apt-get update
root@ubuntu-hhvm:~# apt-get upgrade

Installing HHVM

The installation of HHVM is a very simple process that can be done in different ways. We are going to install it from its prebuilt packages for Ubuntu 14.04 (amd64) by executing following set of commands.

Add apt Repository

root@ubuntu-hhvm:~# apt-get install software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
software-properties-common is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 52 not upgraded.

root@ubuntu-hhvm:~# apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
root@ubuntu-hhvm:~# add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main"

root@ubuntu-hhvm:~# apt-get update
root@ubuntu-hhvm:~# apt-get install hhvm

Once the HHVM installation completes we will have the following output and need to follow the instructions for running PHP web scripts with HHVM

HHVM Install Confirmation

HHVM should have been install with above commands, to make sure its installation we can check it by following commands.

root@ubuntu-hhvm:~# hhvm --version
HipHop VM 3.8.0 (rel)
Compiler: tags/HHVM-3.8.0-0-gbb32f8d645b28561d8491870c44730b9b3f08d35
Repo schema: 74bee5d310450724cfd49245fd6c2e1e4323b10a

If you able to get the version number in result of above command as shown then its means that we have successfully installed HHVM on Ubuntu.

Testing HHVM

Create a new file PHP script file with some text in it like “Hello World This is Test” to test it from the command line using HHVM.

root@ubuntu-hhvm:~# vim test.php

Press “ i ” to change the editor into insertion mode and write the test script.

echo "Hello World This is Test";

Now press “Esc” and write quit the operation to save changes as.


Now, execute the PHP script and its output should be like the same text that we inserted in it.

root@ubuntu-hhvm:~# hhvm test.php

Using HHVM with Apache or Nginx

To start using HHVM with our default web browser we need to execute the following command in case of Apache Web server.

root@ubuntu-hhvm:~# /usr/share/hhvm/install_fastcgi.sh

The executed command will check apache server is installed or not then enable some modules and restart Apache web server services.

Testing HHVM with PHP Script

Stepping forward now we make sure the installed HHVM setup is working fine with Apahe/Nginx PHP scripts. To do so let’s create a new php script file into the document root directory of your web server that /var/www in Apache and /usr/share/nginx/html if you are using Nginx.

root@ubuntu-hhvm:~# cd /var/www/
root@ubuntu-hhvm:/var/www# vim test.php

Add the following php script to this file and then save changes.

echo defined('HHVM_VERSION') ? 'Great! You are Using HHVM' : 'Sorry! Not using HHVM';

Then Open your favorite web browser and access this file by giving it location path on web like below.


The output should be like this Great! You are Using HHVM and you get the output like 'Sorry! Not using HHVM then its mean your HHVM is not functioning.

Awesome! Our output shows that our HHVM server setup is perfect and can used with your web browser.


In this tutorial we learn about HHVM server’s installation and it’s configuration on Ubuntu to serve our PHP based websites like Facebook to serve more users with less system resources. If face any difficulty during its setup don’t hesitate to leave your valuable comments, we will get back to you.

Would you like to know about Zuul, a CI/CD project gating tool? Download our white paper and get reading!

How to up your DevOps game with Project Gating

Share on Social Media:


Cluster API driver for OpenStack Magnum

Mohammed Naser

Public Cloud

9000 MTUs (jumbo frames) in all Public Cloud Regions

Mohammed Naser


OpenInfra Summit Berlin 2022 VEXXHOST Recap

Mohammed Naser

Go to Top