2014-09-29

HHVM, stands for HipHop Virtual Machine, is an open source virtual machine developed by Facebook development team. It is designed for executing massive amount of codes written in Hack and PHP languages. HHVM gives superior performance, and improves the efficiency of PHP execution, and increases the productivity for the developers. The developers says that compared with the regular Zend PHP 5.2 engine + APC, HHVM has realized over a 9x increase in web request throughput and over a 5x reduction in memory consumption for Facebook. This is how Facebook handling millions of active users everyday. According to this blog, the wordpress sites running with HHVM delivers better overall performance, approximately 63%, than the websites which are running using traditional LAMP stack (Apache, MySQL, and PHP). Sounds awesome? Indeed!

HHVM will work on all modern operating systems such as GNU/Linux, Windows, and Mac OS.

HHVM has many features including the following:

The Hack Language;

JIT Compilation;

HNI;

FastCGI support;

Increasing PHP5 Parity;

hphpd debugger;

… and more.

Well, let us see how to install it on a Linux system.

Installing HHVM On Ubuntu 14.04

Run the following commands to add HHVM repository, and install hhvm package.

For other distribution’s installation instructions, please refer the official page given in the bottom this article.

After the installation has finished, you may get the following result.

In my Ubuntu 14.04 server, I got the following result.

As you see in the above result, HHVM gives us the script to install and configure FastCGI for our webserver.

For example, If you use apache web server, then run the following commands:

For nginx web server, run the following commands:

If you want to start hhvm service automatically on ever reboot, run the following command:

Now, check whether HHVM is installed properly by running the following command.

Oops! You might get the following error.

To fix this error, install the missing dependency package “libgmp10″ by entering the following command:

Then, restart the hhvm service:

You should be able to see something like this:

Type quit to return back to your Terminal session.

The following command shows you how to use hhvm.

Sample output:

Testing PHP scripts using HHVM

Let us create a sample php scrip called “unixmen.php”.

Add the following lines:

Save and close the file.

Run the following command to test the script.

Sample output:

Configuring HHVM in the FastCGI mode with Apache Web server

As of version 3.0, HHVM no longer supports the built-in webserver, You should use your own webserver (nginx or apache) talking to HHVM over fastcgi.

First install apache web server in Ubuntu server as shown below.

To check whether the apache is working, open up your web browser, and navigate to the URL http://ip-address. You may see the following like screen.



Now, enter the following commands to configure HHVM in the FastCGI mode with apache web server.

HHVM will be automatically configured for apache server, so you don’t have to do anything. You may notice that the php.ini, and server.ini files have been created automatically under the directory /etc/hhvm/.

Sample output:

Sample output:

Configuring HHVM in the FastCGI mode with nginx Web server

Install nginx package:

To check whether the nginx server is working, open up your web browser, and navigate to the URL http://ip-address. You may see the following like screen.



Now, enter the following commands to configure HHVM in the FastCGI mode with nginx web server.

HHVM will be automatically configured for nginx. You may see the hhvm.conf will be created automatically.

Let us check the contents of hhvm.conf file.

Sample output:

If you have used php-fpm before, the above lines will look familiar to you.

Also, check /etc/nginx/sites-available/default file to verify whether this hhvm.conf has been included.

Sample output:

Scroll down to the server derivative. You should the file hhvm.conf has been included already.

That’s it. Cheers!

Source & Reference link:

HHVM Website

---------------------------------------------------------------------
HHVM – An Open Source PHP Virtual Machine Developed By Facebook

Show more