Quantcast
Channel: linoxide.com
Viewing all articles
Browse latest Browse all 1507

How to Setup HHVM with NGINX on Ubuntu 15.04

$
0
0

Hello! In this article we are going to setup an open source virtual machine that is designed for executing the programs written in Hack and PHP with NGINX web server where as Hack is a programming language for the Hiphop Virtual Machine created by facebook as a dialect of PHP. So this tutorial is going to be interested once get used of it and will be able to speed up your PHP applications. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance while maintaining the development flexibility that PHP provides. Let’s follow the below steps to install and configure HHVM in your environment.

HHVM

System Requirements

HHVM setup only supports 64-Bit Operating system, so make sure that you have installed your operating system that supports 64-Bit architecture. Then you must have super user privileges to perform the required tasks.

You can check your system architecture and other host information with below command.

root@ubuntu-15:~# hostnamectl

Host Information

Its always been been a good practice that your system should be proper updated before you setup any application. To update your operating system you can simply run the below command.

root@ubuntu-15:~# apt-get update

NGINX Installation

As we will be doing the HHVM setup using NGINX web server, so its must be installed prior to the installation of HHVM. You are to use use any other web server like Apache as per your organizational requirements.

Let’s run the following command to install Nginx web server on ubuntu 15.04.

root@ubuntu-15:~# apt-get install nginx

During the installation process you will be asked to continue with the installation operation, so press “Y” to continue as shown below to get your Nginx web server installed.

Nginx Installation

Now check the services of Nginx web server, it should be running and enabled as default. You can check and start its services as below.

root@ubuntu-15:~# service nginx start
root@ubuntu-15:~# service nginx status

Nginx Service Status

The Nginx status show the active status of running services.

HHVM Installation

Now let’s proceed with installation of Hip Hop Virtual Machine on Ubuntu 15.04. As its package is not available in Ubuntu’s built in repository that why we have to add the HHVM repository to our Ubuntu repository file “/etc/apt/sources.list” and then update the repository by using the following commands in the terminal.

root@ubuntu-15:~# wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add –

HHVM Source

root@ubuntu-15:~# echo deb http://dl.hhvm.com/ubuntu vivid main | sudo tee /etc/apt/sources.list.d/hhvm.list

To update the newly added repositories once again run the update command so that the installation package of HHVM will be available through its Ubuntu Repository list.

root@ubuntu-15:~# apt-get update

Once your system is up-to-date, run the following command to start the installation of HHVM package.

root@ubuntu-15:~# apt-get install -y hhvm

The installation will be done with addition of some extra packages as shown.

HHVM Install

At the end of installation process of HHVM you will see its installation complete message with addition to some instructions to getting started with HHVM usage.

hhvm installation

HHVM Configuration with Nginx

When the installation is finished, now we need to configure the Nginx web server to use HHVM as per instructed above. So, let’s issue the below command as shown.

root@ubuntu-15:~# /usr/share/hhvm/install_fastcgi.sh

It will check for the installed web server, enable its module and then restart its services.

hhvm web setup

To use HHVM for “/usr/bin/php” even if you have “php-cli” installed, run the below command.

root@ubuntu-15:~# /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60

Now start HHVM service and check its status if everything is fine.

root@ubuntu-15:~# service hhvm status

hhvm status

Testing HHVM

In order to test HHVM for the confirmation if everything is installed and configured properly we will create a php file in the document root directory of your web server, restart Nginx services and then access it from the browser.

root@ubuntu-15:~# vim /var/www/html/info.php

"
phpinfo();
:wq!

root@ubuntu-15:~#service nginx restart

Now open your web browser and access the “info.php” file after saving the changes with and restart of Nginx services.

http://your_server_IP/info.php

hhvm web test

Conclusion

You have HHVM running on your Ubuntu 15.04 node which is much capable to serve PHP scripts more faster and efficient with Nginx on the top of your websites. Its gives you the big advantage of its fast speed than really all of Magento is faster, including payment and backend also by using HHVM to execute PHP, a lot less CPU power is used.

The post How to Setup HHVM with NGINX on Ubuntu 15.04 appeared first on LinOxide.


Viewing all articles
Browse latest Browse all 1507

Trending Articles