How To Install HHVM 3.2.0 On CentOS 6.5

by admin on November 6, 2014

HipHop Virtual Machine (HHVM) is a process virtual machine based on just-in-time (JIT) compilation, serving as an execution engine for PHP and Hack programming languages. By using the principle of JIT compilation, executed PHP or Hack code is first transformed into intermediate HipHop bytecode (HHBC), which is then dynamically translated into the x86-64 machine code, optimized and natively executed.

According to their website, HHVM has realized over a 9x increase in web request throughput and over a 5x reduction in memory consumption for Facebook compared with the Zend PHP engine + APC (which is the current way of hosting a large majority of PHP applications).

Installing HHVM

Installing HHVM is quite straightforward and shouldn’t take more than a few minutes.
Login as root and execute the following commands from the command line will have HHVM installed and ready:

# cd /etc/yum.repos.d
# wget http://www.hop5.in/yum/el6/hop5.repo
# yum install hhvm

Sample output

Dependencies Resolved

================================================================================
 Package                   Arch       Version                    Repository
                                                                           Size
================================================================================
Installing:
 hhvm                      x86_64     3.2.0-1.el6                hop5     9.6 M
Installing for dependencies:
 GConf2                    x86_64     2.28.0-6.el6               base     964 k
 ImageMagick               x86_64     6.8.6.3-4.el6              hop5     138 k
 ImageMagick-libs          x86_64     6.8.6.3-4.el6              hop5     1.9 M
 ORBit2                    x86_64     2.14.17-5.el6              base     168 k
 OpenEXR-libs              x86_64     1.6.1-8.1.el6              base     197 k
 boost                     x86_64     1.54.0-7.el6               hop5      32 k
 boost-atomic              x86_64     1.54.0-7.el6               hop5      34 k
 boost-chrono              x86_64     1.54.0-7.el6               hop5      40 k
 boost-context             x86_64     1.54.0-7.el6               hop5      33 k
 boost-date-time           x86_64     1.54.0-7.el6               hop5      47 k
 boost-filesystem          x86_64     1.54.0-7.el6               hop5      63 k
 boost-graph               x86_64     1.54.0-7.el6               hop5     126 k
 boost-iostreams           x86_64     1.54.0-7.el6               hop5      55 k
 boost-locale              x86_64     1.54.0-7.el6               hop5     251 k
 boost-log                 x86_64     1.54.0-7.el6               hop5     599 k
 boost-math                x86_64     1.54.0-7.el6               hop5     324 k
 boost-program-options     x86_64     1.54.0-7.el6               hop5     145 k
 boost-python              x86_64     1.54.0-7.el6               hop5     124 k
 boost-random              x86_64     1.54.0-7.el6               hop5      36 k
 boost-regex               x86_64     1.54.0-7.el6               hop5     298 k
 boost-serialization       x86_64     1.54.0-7.el6               hop5     155 k
 boost-signals             x86_64     1.54.0-7.el6               hop5      56 k
 boost-system              x86_64     1.54.0-7.el6               hop5      36 k
 boost-test                x86_64     1.54.0-7.el6               hop5     212 k
 boost-thread              x86_64     1.54.0-7.el6               hop5      55 k
 boost-timer               x86_64     1.54.0-7.el6               hop5      38 k
 boost-wave                x86_64     1.54.0-7.el6               hop5     198 k
 fftw                      x86_64     3.2.1-3.1.el6              base     1.2 M
 gd                        x86_64     2.0.35-11.el6              base     142 k
 ghostscript               x86_64     8.70-19.el6                base     4.4 M
 ghostscript-fonts         noarch     5.50-23.2.el6              base     590 k
 glog                      x86_64     0.3.2-1.el6                hop5      48 k
 ilmbase                   x86_64     1.0.1-6.1.el6              base      72 k
 jemalloc                  x86_64     3.6.0-1.el6                epel     100 k
 lcms2                     x86_64     2.3-2.el6                  epel     127 k
 libICE                    x86_64     1.0.6-1.el6                base      53 k
 libIDL                    x86_64     0.8.13-2.1.el6             base      83 k
 libSM                     x86_64     1.2.1-2.el6                base      37 k
 libXfont                  x86_64     1.4.5-3.el6_5              base     136 k
 libXt                     x86_64     1.1.4-6.1.el6              base     165 k
 libcroco                  x86_64     0.6.2-5.el6                base     100 k
 libdwarf                  x86_64     20140413-1.el6             epel     108 k
 libfontenc                x86_64     1.0.5-2.el6                base      24 k
 libgsf                    x86_64     1.14.15-5.el6              base     116 k
 libicu                    x86_64     4.2.1-9.1.el6_2            base     4.9 M
 libmcrypt                 x86_64     2.5.8-9.el6                epel      96 k
 libmemcached              x86_64     1.0.16-1.el6               hop5     208 k
 libmpc                    x86_64     0.8.3-0.3.svn855.el6       hop5      47 k
 librsvg2                  x86_64     2.26.0-14.el6              base     140 k
 libtool-ltdl              x86_64     2.4.2-21.el6               hop5      46 k
 libunwind                 x86_64     1.1-2.el6                  epel      54 k
 libwmf-lite               x86_64     0.2.8.4-23.el6             base      51 k
 libxslt                   x86_64     1.1.26-2.el6_3.1           base     452 k
 mysql                     x86_64     5.1.73-3.el6_5             base     894 k
 ocaml                     x86_64     3.12.1-12.el6              hop5     5.5 M
 ocaml-runtime             x86_64     3.12.1-12.el6              hop5     1.4 M
 oniguruma                 x86_64     5.9.1-3.1.el6              base     123 k
 sgml-common               noarch     0.6.3-33.el6               base      43 k
 tbb                       x86_64     4.0-7.20120408.el6         hop5     103 k
 unixODBC                  x86_64     2.2.14-14.el6              base     378 k
 urw-fonts                 noarch     2.4-10.el6                 base     3.1 M
 xorg-x11-font-utils       x86_64     1:7.2-11.el6               base      75 k
Updating for dependencies:
 cpp                       x86_64     4.8.2-8.el6                hop5     5.7 M
 curl                      x86_64     7.29.0-4.el6               hop5     256 k
 gcc                       x86_64     4.8.2-8.el6                hop5      17 M
 gcc-c++                   x86_64     4.8.2-8.el6                hop5     6.9 M
 libcurl                   x86_64     7.29.0-4.el6               hop5     198 k
 libcurl-devel             x86_64     7.29.0-4.el6               hop5     294 k
 libevent                  x86_64     1.4.14b-2.hphp.el6         hop5      66 k
 libgcc                    x86_64     4.8.2-8.el6                hop5      83 k
 libgomp                   x86_64     4.8.2-8.el6                hop5     100 k
 libstdc++                 x86_64     4.8.2-8.el6                hop5     289 k
 libstdc++-devel           x86_64     4.8.2-8.el6                hop5     1.5 M

Transaction Summary
================================================================================
Install      63 Package(s)
Upgrade      11 Package(s)

Total download size: 73 M
Is this ok [y/N]: y

To confirm that HHVM has been installed, type the following command:

# hhvm --version

This will show details of how the hhvm command can be used from the command line. Here is a sample screenshot that illustrates this:

HipHop VM 3.2.0 (rel)
Compiler: tags/HHVM-3.2.0-0-g01228273b8cf709aacbd3df1c51b1e690ecebac8
Repo schema: c52ba40f4a246d35a88f1dfc1daf959851ced8aa

Using Nginx with HHVM

If you are using Nginx with PHP-FPM, you’ll have to modify the configuration file to enable the use of HHVM.

Look for the following section and make sure it’s all uncommented (by remove a # at the beginning of each line)

location ~ \.php$ {
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_index index.php;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       include fastcgi_params;
}

Create a file called name “hhsvr” to start or restart HHVM service

# vi /usr/bin/hhsrv
# chmod +x /usr/bin/hhsrv

Append

#!/bin/bash
LOG="/var/log/hhvm.log"
CMD="hhvm --mode server -vServer.Type=fastcgi -vServer.Port=9000"
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
        echo "To restart HHVM: /usr/bin/hhsrv restart|stop\n"
        exit;
fi

# Restart HHVM
if [ "$1" == "restart" ]; then
        PID=$(ps aux | grep -v grep | grep hhvm | awk '{print $2}')
        echo "Restarting HHVM..."
        if [ "${PID}" != "" ]; then
                kill -9 ${PID}
        fi
        echo "Starting HHVM ..."
        ${CMD} > /dev/null 2>&1 &
        echo "DONE !!!"
fi

# Stop HHVM
if [ "$1" == "stop" ]; then
        PID=$(ps aux | grep -v grep | grep hhvm | awk '{print $2}')
        echo "Restarting HHVM..."
        if [ "${PID}" != "" ]; then
                kill -9 ${PID}
        fi
        echo "HHVM stopped !!!"
fi

Final, Type the following command to start HHVM

# hhsrv restart

Related Posts:

Leave a Comment

Previous post:

Next post: