How to Install HipHop Virtual Machine (HHVM) on an Ubuntu 17.04 VPS or Dedicated Server

How to Install HipHop Virtual Machine (HHVM) on an Ubuntu 17.04 VPS or Dedicated Server

Most of the websites and application we have today are powered by the LAMP stack, consisting of Linux, PHP, MySQL, and the Apache web server software.

A popular alternative to PHP in the LAMP stack is HHVM (HipHop Virtual Machine). It’s an open-source system designed to execute a variety of programs written in Hack code and PHP. It is developed by Facebook to run scripts and programs written in PHP. Facebook developed this service to improve performance and serve the large applications built in PHP, something both Zend and Apache cannot achieve.

HHVM utilizes its essential principle of just-in-time (JIT) technique to achieve excellent performance and maintain high flexibility offered by PHP. HHVM helps to execute Hack code and PHP into intermediate bytecode and then translates them dynamically into x64 machine code.

Since HHVM is powerful, it requires more CPU and RAM compared to other lightweight PHP dealers such as PHP-FPM.

In this guide, we will take through you step-by-step on how to install HHVM on Ubuntu systems (version 17.04).

Special Note: using a specialized Linux hosting plan will allow you to enjoy expert Linux support. This can be a major help if you run into trouble performing more complex installations.  Check out the Linux Hosting services featured on HostAdvice.


For this article, you will need:

  • A sudo non-root user
  • Ubuntu 17.04 Droplet
  • Installed Nginx

Step 1: Installation on Ubuntu 17.04

For installation on Ubuntu 17.04, ensure the system packages are updated by running the commands below:

$ sudo apt-get update
$ sudo apt-get upgrade

Now, add HHVM repository on your virtual machine before you proceed with the installation.

$ sudo apt-get install software-properties-common
$ sudo apt-key adv --recv-keys --keyserver #hkp:// 0x5a16e7281be7a449

To add the repository to Ubuntu system, run the command below:

$ sudo add-apt-repository "deb $(lsb_release -sc) main"

Finally, install HHVM using the command below:

$ sudo apt-get install hhvm

This command will automatically install HHVM and start it immediately. To ensure the installation starts and stops automatically with Droplet, add HHVM to your default settings with the command below:

$ sudo update-rc.d hhvm defaults

To ensure HHVM has been installed successfully, run the following command:

$ php -v

#HipHop VM 3.15.0 (rel)
Compiler: tags/HHVM-3.15.0-0-g92a682ebaa3c85b84857852d8621f528607fe27d
Repo schema: 225d4323575bbc8a498dc809a1c41354f6bca83

Step 2: Configuring HHVM on Ubuntu 17.04

HHVM comes with an excellent script to install FastCGI based on a web server in your system.  In this section, we shall configure HHVM with the Apache and Nginx servers.


To install Apache server, run the command below:

$ sudo apt-get install -y apache2

Then configure HHVM in the FastCGI with Apache using the following command:

$ sudo /usr/share/hhvm/


Once you run the script above, it adds a configuration file written as /etc/nginx/hhvm.conf to the default configuration of the Nginx server written as /etc/nginx/sites-enabled/default.

If you are using Nginx with PHP-FPM, then you will need to manually replace the previous FastCGI configuration with the text below:

location ~ \.(hh|php)$ {
    fastcgi_keep_conn on;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;

Restart Nginx on your machine to apply these changes.

$ sudo service nginx restart

The process assumes that the default configuration of HHVM hasn’t changed. The setting originates from the main HHVM configuration file written as /etc/hhvm/server.ini and contains the following information.

; php options

pid = /var/run/hhvm/pid

; hhvm specific

hhvm.server.port = 9000
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc

In this configuration, the variable hhvm.server.port shows that HHVM is expected to listen to TCP port 9000. By default, it should listen on the localhost.

HHVM is ideal for heavy load configuration, so the first step is to change the ports and ensure HHVM is listening to socket instead of the TCP port.

To do so, open the file name /etc/hhvm/server.ini and run the command below:

$ sudo vim /etc/hhvm/server.ini

Spot the line hhvm.server.port and delete it then replace it with the text below:


Save the file, and restart HHVM to apply these changes. Use the command below:

$ sudo service hhvm restart

Update the system to ensure it applies to Nginx too. To do so, open the file /etc/nginx/hhvm.conf and edit as shown below:

$ sudo vim /etc/nginx/hhvm.conf

Ensure the fastgi_pass is directed to the HHVM socket and should be displayed in the format below:

fastcgi_pass unix:/var/run/hhvm/hhvm.sock;

Restart Nginx to apply these changes using the following command:

$ sudo service nginx restart

Step 3: Testing HHVM

The first critical test you can perform is the PHP command/usr/bin/php with directives that point to /etc/alternatives/php which finally points to HHVM.

/usr/bin/php --version

Once you run this command, the output should show a printed version of HHVM plus relevant repository information as shown below:

HipHop VM 3.8.1 (rel)
Compiler: tags/HHVM-3.8.1-0-g3006bc45691762b5409fc3a510a43093968e9660
Repo schema: 253b3802ce1bcd19e378634342fc9c245ac76c33

In case you have installed PHP before HHVM, it’s still possible to see the output from the previous PHP. If you want to change it and point it to HHVM, use the command below:

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

To view the HHVM settings, use the function phpinfo(). You need to create a new file in your default document /usr/share/nginx/html and run the command below:

$ sudo vim /usr/share/nginx/html/info.php
Your file should contain the following:

Try to access your files from your IP on Droplet. The address should look like this:


Make sure your browser results resemble the output below:

If this image does not appear, make sure you check the installation process again from the beginning. Also, check for errors in Nginx and HHVM.


Congratulations! Now you have successfully installed HHVM. We hope this tutorial will help you install HHVM on your Ubuntu 17.04.


Check out these top 3 Linux hosting services

$1.79 /mo
Starting price
Visit FastComet
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
$4.00 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing

Part Two: How to Monitor Nginx using Elastic Stack on a CentOS 7 VPS or Dedicated Server

This tutorial will explain how to use the different components of the Elastic St
3 min read
Idan Cohen
Idan Cohen
Marketing Expert

Part One: How to Monitor Nginx using Elastic Stack on a CentOS 7 VPS or Dedicated Server

This is Part I of a two-part tutorial explaining how to use the different compon
5 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Configure Nginx as Reverse Proxy for Apache on an Ubuntu 16.04 VPS or Dedicated Server

This guide is compiled to help you learn how to install Nginx as a reverse proxy
4 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to install Django on a CentOS 7 VPS or Dedicated Server

When building a website, similar components are required, and you do not have to
3 min read
Mark Armistead
Mark Armistead
Author provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top