Verified and Tested 8/5/15
This guide will show you how to install HHVM (HipHop Virtual Machine) on an Ubuntu 14.04 server using Apache or Nginx. HHVM is a process virtual machine designed to execute Hack and PHP programs. HHVM runs programs at run time rather than prior, which gives HHVM high-caliber performance over a typical PHP install. HHVM was open-sourced and developed by Facebook.
– A server with Ubuntu 14.04 installed. HHVM requires the 64-bit version. If you do not have a server, try a market-leading Virtual Private Server in under 30 seconds from Atlantic.Net
– Apache or Nginx installed on your server. You can follow our guides on installing Apache or Nginx if needed.
Installing HHVM on Ubuntu 14.04 using Apache or Nginx
First we need to add the HHVM key to your Ubuntu Server with the following command:
sudo wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add -
Next we are going to add the HHVM source to your sources list with the following command:
sudo echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list
Now that we added the key and sources it is a good idea to run and update with the following command:
sudo apt-get update
Now we can install HHVM with the following command:
sudo apt-get install hhvm
Make it start on boot by running the command:
sudo update-rc.d hhvm defaults
HHVM includes an excellent script to install FastCGI based on web server you have installed. Run it with the following command:
Note: On Apache there have been issues with hhvm_proxy_fcgi.conf not matching the default directory and when you access PHP sites you get a 404 File Not Found. To fix this, use your favorite text editor open the following file:
Within the file find the line that says:
proxypassmatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/$1
Then replace it with the following:
ProxyPassMatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1
You can now test it by making a sample PHP page and going to your web browser.
For Nginx open your editor and create the file:
For Apache open your editor and create the file:
Then add the following code to your new file.
Now test it by opening up your web browser and going to yourhostname.com/info.php
You should get a page similar to the one below.
An example of the HHVM info page
It is a good idea to delete your info.php file as it could be used to attack your server.
Sample Commands for HHVM you may find useful
Start HHVM with:
service hhvm start
Stop HHVM with:
service hhvm stop
Restart HHVM with:
service hhvm restart
You can also see if HHVM is version with the following command:
Congratulations on installing HHVM on Ubuntu 14.04. Try it out with some of your favorite CMS’s like WordPress or Drupal and you should see a performance increase especially under load. Thank you for following along this how to, please check back for more updates.