LinuxTutorialsUbuntu

How To Install HHVM on Ubuntu 16.04 LTS

Install HHVM on Ubuntu 16.04 LTS

In this tutorial, we will show you how to install and configure HHVM on Ubuntu 16.04 LTS. For those of you who didn’t know, HipHop Virtual Machine (HHVM) is a virtual machine developed and open-sourced by Facebook to process and execute programs and scripts written in PHP. Facebook developed HHVM because the regular Zend+Apache combination isn’t as efficient to serve large applications built in PHP.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of HHVM (HipHop Virtual Machine) on a Ubuntu 16.04 (Xenial Xerus) server.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 16.04 (Xenial Xerus).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install HHVM on Ubuntu 16.04 LTS

Step 1. First, make sure that all your system packages are up-to-date by running the following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Installing HHVM.

First, we need to add the HHVM repository to your Ubuntu Server with the following command:

apt-get install software-properties-common
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main"

Now we can install HHVM with the following command:

apt-get update
apt-get install -y hhvm

HHVM should have been successfully installed, to make sure to run the following command:

$ php -v

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

HHVM includes an excellent script to install FastCGI based on the web server you have installed. This section will help you configure HHVM in the FastCGI mode with the Apache and Nginx servers:

With Apache

Configuring HHVM to work in the FastCGI mode with Apache is extremely simple. All you need to do is execute the following script:

sudo /usr/share/hhvm/install_fastcgi.sh

With Nginx

If you are using Nginx with PHP-FPM, you’ll have to modify the configuration file to disable the use of PHP-FPM. This file is normally located at /etc/nginx/sites-available/default. Look for the following section and make sure it’s all commented (by adding a # at the beginning of each line):

# 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;
#}

After doing this, execute the following script:

sudo /usr/share/hhvm/install_fastcgi.sh

Finally, run the commands below to start up HHVM:

systemctl start hhvm

Step 3. Testing HHVM.

To test HHVM, create a test page in the root directory and type these lines in the file and save it:

nano /var/www/html/hhvminfo.php

Then add the following code to your new file:

<?
php phpinfo();
?>

Try to access it at http://your_ip_address/hhvminfo.php. If the PHP info page is rendered in your browser then everything looks good and you are ready to proceed further.

Install HHVM on Ubuntu 16.04 LTS

Congratulations! You have successfully installed HHVM. Thanks for using this tutorial for installing HHVM (HipHop Virtual Machine) on your Ubuntu 16.04 LTS  (Xenial Xerus) system. For additional help or useful information, we recommend you to check the official HipHop Virtual Machine website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Save

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button