• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » HipHop Virtual Machine (HHVM)

By Abhishek Ghosh November 2, 2014 5:54 pm Updated on November 2, 2014

HipHop Virtual Machine (HHVM)

Advertisement

HipHop Virtual Machine (HHVM) is a process virtual machine developed by Facebook, serves as an execution engine for PHP, based on JIT. HipHop Virtual Machine (HHVM) is an Open Source Software like PHP. We can install HipHop Virtual Machine (HHVM) on the top of Nginx Web Server Software, that is the basic importance to know about HipHop Virtual Machine. HipHop for PHP (HPHPc) was also developed by Facebook, a PHP transpolar and HipHop Virtual Machine (HHVM) is the succeeder.

 

HipHop Virtual Machine (HHVM) : Basics

 

We usually use PHP5-FPM with Nginx Web Server Software. Instead of only running PHP5-FPM, basically we can use HipHop Virtual Machine (HHVM) on FastCGI-based web server, on a developmental setup first and later adjust setting to deploy on production server. FastCGI support for HHVM was not available before December 2013. PHP5-FPM is a FastCGI Process Manager. So, practically we can compare the performance of PHP5-FPM versus HHVM. If we want to run WordPress, normally, HHVM with PHP-FPM fallback is used. HHVM might not support all the WordPress themes and plugins.

A process virtual machine or application virtual machine or Managed Runtime Environment (MRE), runs like a normal application inside a Linux based host OS and supports a single process. Exit means destruction of the virtual machine. The basic purpose of process virtual machine is to provide a programming environment that provides an abstraction layer away from the underlying hardware or Host OS. It allows a program to get executed. Process virtual machines usually provide a high-level abstraction for high-level programming language. In practice, the process virtual machines are implemented using an interpreter and just-in-time compilation. They have a dedicated website :

Advertisement

---

http://hhvm.com

Hacks will be available on the official website, as well as more information. Just to tell you – the just-in-time compilation can be used on Nginx on other ways. Facebook possibly developed HHVM as Zend and Apache2 web server combination is probably not great to resource hungry applications written in PHP. PHP is bad, well accepted; but we need to use PHP as there are lesser projects written in Python, Ruby, Perl.

Knowing theory on HipHop Virtual Machine (HHVM) is great, but whether HipHop Virtual Machine will work properly on production server for WordPress, we can not give warranty. Facebook developed for their own purpose. You can test.

HipHop Virtual Machine (HHVM)

 

Using HipHop Virtual Machine (HHVM) with Nginx on Ubuntu

 

You need to have pcre-jit on Nginx. If Nginx was installed before, you should check the compilation by running nginx -V command. Possibly the latest aptitude version of Nginx has no bug with pcre-jit. In other words – probably building Nginx from source will be better, although apt-get install nginx should make pcre-jit to work or run fine. If apt-get install nginx does not work, you have to stop nginx and recompile from source or fully uninstall nginx, clear cache and freshly build.

So much words has been used or abused as you might want just to test HHVM on an existing setup.

First, for Nginx, we need to install the dependencies :

Vim
1
apt-get update && apt-get install libpcre3-dev build-essential libssl-dev dpkg-dev build-essential zlib

wget nginx, unzip it and cd to the directory and compile in this way :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
./configure \
--with-http_ssl_module \
--with-pcre-jit \
--with-ipv6 \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_geoip_module \
--with-http_gzip_static_module \
--with-http_spdy_module \
--with-http_sub_module \
--with-http_xslt_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio
CFLAGS="-O3" CXXFLAGS="-O3" make

make install is the next command and you have to copy to the right directory. We deliberately kept the Nginx part short yet at least understandable.

This is the official way to install HHVM :

Vim
1
2
3
4
5
6
7
8
9
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
# next command
echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list
# next command
apt-get update && apt-get install hhvm
# optional to solve bugs
apt-get install libgmp-dev && apt-get install libmemcached-dev
# help command
hhvm --help

There are at least two use HHVM. One is using supervisord and another is the regular way. We are taking the regular way. If it is an empty server, delete any existing html file from the public root directory and create a php file :

Vim
1
2
3
4
5
6
7
8
9
10
11
nano index.php
# copy and paste
<?php
echo '<h1>HipHop Virtual Machine (HHVM) Works!</h1>';
# ^ + O
# ^ + X
# nano is the text editor
# start server
hhvm -m server
# execute this script
/usr/share/hhvm/install_fastcgi.sh

Test by visiting the webpage on browser. If PHP5-FPM was used, you need to comment out these from your default nginx ghost config file, default is /etc/nginx/sites-available/default:

/etc/nginx/sites-available/default
Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
nano /etc/nginx/sites-available/default
 
# Edit it by finding with ^ + W
 
# 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;
#}
 
# Edit ends
# ^ + O
# ^ + X
# add HHVM at boot, do not do before you know
# what you are doing
update-rc.d hhvm defaults
# restart nginx
nginx -v
# assuming no bad output
service nginx restart
# you should add runtimes by manually checking !
https://github.com/facebook/hhvm/tree/master/hphp/runtime/ext

This is not fallback to PHP5-FPM setup. If you wanted fallback, instead of editing the file above, we would approach in this way :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
nano /etc/hhvm/server.ini
# change server port from 9000 to 8000
# ^ + W
hhvm.server.port = 8000
# Edit ends
# ^ + O
# ^ + X
nano /etc/hhvm/php.ini
# add these at the end, no ; at the end of each
hhvm.log.header = true
hhvm.log.natives_stack_trace = true
# Edit ends
# ^ + O
# ^ + X
nano /etc/nginx/hhvm.conf
# this should be the value
fastcgi_pass 127.0.0.1:8000;
# Edit ends
# ^ + O
# ^ + X
nano /etc/nginx/conf.d/fastcgi.conf
# add this at the end
fastcgi_keep_conn on;
# Edit ends
# ^ + O
# ^ + X
nano /etc/nginx/conf.d/upstream.conf
# edit or modify properly
upstream php {
server 127.0.0.1:8000;
server 127.0.0.1:9000 backup;
}
upstream debug {
# pool
server 127.0.0.1:9001;
}
# Edit ends
# ^ + O
# ^ + X
## restart all the services
service hhvm restart
php5-fpm -t
# hope right output
service php5-fpm restart
nginx -t
# hope right output
service nginx restart

There is no issue with KVM or Xen virtualization, but with OpenVZ there can be issue with HipHop Virtual Machine (HHVM). The above stuff is for Rackspace Cloud Server. This might not work on Amazon or DigitalOcean (we have not tested).

Tagged With Hip Hop Virtual Machine
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to HipHop Virtual Machine (HHVM)

  • Install WordPress on Nginx With HHVM on Ubuntu Cloud Server

    Here is Step by Step Guide to Install WordPress on Nginx With HHVM on Ubuntu Cloud Server. This simple and most easy standalone HHVM only guide. We talked about HipHop Virtual Machine or HHVM in order article. Normally, with Nginx, we use PHP5-FPM. This guide is how to install WordPress on Nginx with HHVM on […]

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud

    Here is a Step by Step Guide on Setting Up WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud with All Commands and the Configuration.

  • XCache Admin Page on Nginx-PHP5-FPM (Ubuntu, HP Cloud)

    Here is How to Setup a XCache Admin Page on Nginx-PHP5-FPM on Ubuntu Instance Running on HP Cloud. It Gives a Clear Graphical Idea of Caching.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy