Install HHVM on Ubuntu 17.04 / 17.10

The LAMP stack consists of Linux, Apache2, MySQL or MariaDB and PHP. It’s an opensource stack that powers majority of the websites and applications online today.

One popular alternative to PHP of the LAMP stack is HHVM. HHVM is an open-source virtual machine designed for executing programs and applications written in PHP. You can use HHVM in place of PHP of the LAMP stack to achieve superior performance.

This brief tutorial is going to show students and new users how to install HHVM on Ubuntu systems to run WordPress and other content management systems based on PHP.

To get started with install HHVM on Ubuntu, follow the guide below.

Step 1: Add HHVM repository to Ubuntu

First run the commands below to download and the repository key on Ubuntu.

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449

Then run the commands below to add its repository to Ubuntu system.

sudo add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main"

Doing the above step will get the application ready to be installed on Ubuntu.

Step 2: Install HHVM

Now that the repository and key have been added to Ubuntu, run the commands below to install HHVM

sudo apt-get update
sudo apt-get install hhvm

After installing hhvm, the commands below can be used to stop, start and enable hhvm to always start up when the server boots.

sudo systemctl stop hhvm.service
sudo systemctl start hhvm.service
sudo systemctl enable hhvm.service

Next, run the commands below to make HHVM answer to all php calls even if php-cli is installed. In some cases, php-cli may conflict with HHVM.

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

After running the commands above, HHVM should be installed and ready to use. To test HHVM installation, run the commands below. To view the test from your browser, you must have Nginx or Apache2 installed.

sudo echo "<?php phpinfo(); ?>" > /var/www/html/info.php

When you browse to your server followed by info.php, you should see the test page with HHVM info.

Enjoy!~

You may also like the post below:

Setup SSH Server for Key Authentication on Ubuntu 17.04 / 17.10