This article gives a short description of Nginx HHVM and MySQL. This article will them define and explain the steps necessary to install all the above mentioned open source software on Ubuntu VPS Server on which we will then install WordPress HHVM so that it may run on it.

All of us must have heard of LAMP and LNMP, but nobody or mostly anybody would know what LNMH is. You must be wondering where the P went. The P that stood for PHP and where did it run off to. But more importantly you must be thinking about what the H part stands for Hack. Well not to worry. We’ve explained all and everything that you need to know in detail:

How To Install HHVM with Nginx on Ubuntu

HHVM:

HipHop Virtual Machine or simply HHVM is a process virtual machine. This process virtual machine works on the sole principle of Just In Time compilation (JIT).This is also used as an execution engine for the Hack Programming Language and for PHP as well. HHVM is developed by Facebook, the reason was that Apache+Zend combination was proven to not be as much efficient as wanted. It failed terribly on the comparatively large applications that were made on PHP. HHVM performed extremely well by proven serving more than a 9 times increase in web request throughput. Its performance was so brilliant that it consumed 5 times less memory for facebook, rather than the Zend PAHP engine + APC. Summarizing our whole talk, we’ll say this; HHVM is basically a virtual machine that is designed, developed and open sourced by Facebook so that it can execute and process scripts and programs that are written in Hack language and PHP. The best way to use HHVM is with a FastCGI based webserver like apache or Nginx.

Nginx:

Nginx, also pronounced as “Engine X” is a web server that has a strong focus on performance and minimum usage of memory. The other thing that it does is that it acts likes a reverse proxy server for HTTP, SMTP, POP3, HTTPS and the IMAP protocols. Other functions of Nginx include its use as a load balancer and a HTTP cache.

Nginx was created in 2002 by Igor Sysoev in 2002. This web server is compatible with UNIX, Linux, and BSD variants, Mac OS X, Solaris, AIX, HP-UX and Microsoft Windows as well. Nginx is free and open source software which was released under the terms of BSD-like license.

MySQL:

MySQL which is officially pronounced as (My-Ess-Que-Ell) and unofficially pronounced as (My-Sequel) is an open source RDBMS (Relational Data Base Management System). According to the survey conducted in January 2013 MySQL was considered the second most widely used relational Data Base Management System and the most widely used open source server-client model RDBMS. The name is thought of after the co-founder Micheal Windenui’s daughter. The SQL acronym in MySQL stands for Structured Query Language. MySQL is available in paid editions which offer more functionality.

PREREQUISITES:

Firstly, we’ll need a server that has Ubuntu installed on it (Vivid Vervet x64). Just so you know, HHVM is not compatible with any 32-bit operating system nor do they plan on adding any support for it. What helped me a lot in this tutorial was Digital Ocean. It lets you create a server and destroy it on an hourly basis so when I need to test something or write a tutorial like this one it almost costs me nothing.

A very basic knowledge of the commands used in UNIX.

A very basic knowledge about Putty or Terminal.

Something to drink like a cup of coffee or tea.

How to Install Nginx on Ubuntu

Step-1:You need to login to your server as a user that has root privileges (sudo). In case you are using a VPS from DO, you’d be asked to change your given password for the root.

Step-2:

Now you need to update all the packages and dependencies of your VPS. You can do that by simply giving it this one command:

apt-get update && apt-get upgrade –y

The screenshot Picture:

Step-3:

Now we need to give a command to install Nginx on your VPS. This will do the trick:

apt-get install nginx –y

It will look something like this:

Installing MySQL Server on Ubuntu

Step-1:By now you have installed Nginx as a web server on your Ubuntu VPS 15.04. So you will do now and install MySQL as your data base server. This server is actually needed by multiple scripts and apps like WordPress and joomla. To install MySQL server you need to issue this command:

apt-get install mysql-server -y

The installation won’t take much time and it’ll be done In a few second. You should see a screen similar to this one:

Step-2:

So when you have installed this you will need to setup a basic MySQL configuration which includes adding a password for you root user.

mysql_secure_installation

Building and installing HHVM on Ubuntu

Step-1:So now you have MySQL and Nginx installed on your Ubuntu VPS 15.04. Now comes the main part of this article which is installing the hiphop virtual machine on your VPS. For that to happen you need to install several commands that will download and install the package that is required for your HHVM installation:

You need to update the apt so that the new repository can now be applied:

apt-get update –y

It will look somewhat like this:

Step-3:

Now all you need to do is to just give a command to install HHVM on your VPS Server:

apt-get update –y

This shouldn’t take more than a few seconds and it should look like this:

If all works out right then you should see this message:

Step-4:

What needs to be done now s that you need to install and run the script that will install HHVM module for you Nginx. Give it this command:

/usr/share/hhvm/install_fastcgi.sh

After you’ve done so, you’ll see something like this:

Configuring NGINX Virtual host for HHVM:

Step-5

So let’s suppose that you want to add a new website. A website like example.com, so what you will do is that you will create a new virtual host file. For this purpose, any text editor can be used. In my guide I will do this using Nano:

Now you know why I asked you to start with a cup of coffee by your side. Finally you go ahead and restart your HHVM and Nginx by these following commands:

service nginx restart
service hhvm restart

Step-10

Now to test what we have created. Let us create a test.php file and confirm if HHVM is working properly or not.

nano /var/www/example.com/test.php

Now add these lines of code in the file:

<?php
echo defined('HHVM_VERSION')?'HHVM is up and working':'Sorry Not using HHVM';
?>

Picture is attached below:

Now to save and exit the file, hit Ctrl+O then Ctrl+X .

Step-11

And finally, open your web browser and after that just open the file that was newly created. And Voila!

HHVM IS UP AND WORKING!!!!!!

That is it. You have HHVM running on your Ubuntu server which is capable of handling PHP scripts. It runs them very fast and efficiently besides which will make your website run even even faster and smoother.