HipHop Virtual Machine (HHVM) is a virtual machine developed and open sourced by Facebook to process and execute programs and scripts written in PHP. Facebook developed HHVM because the regular Zend+Apache combination isn’t as efficient to serve large applications built in PHP.
Table of Contents
Step 1. First let’s start by ensuring your system is up-to-date.
Step 2. Installing Required Dependency.
Step 3. Installing HipHop Virtual Machine (HHVM) on CentOS 7.
Step 4. Config Setup HHVM.
Prerequisites
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root accge of Linount, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation the HipHop Virtual Machine (HHVM) on a CentOS 7 server.
Install HipHop Virtual Machine on CentOS 7
Step 1. First let’s start by ensuring your system is up-to-date.
yum clean all yum -y update
Step 2. Installing Required Dependency.
Install the dependencies for the HHVM installation:
yum localinstall http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm yum localinstall http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install cpp gcc-c++ cmake3 git psmisc {binutils,boost,jemalloc,numactl}-devel \ {ImageMagick,sqlite,tbb,bzip2,openldap,readline,elfutils-libelf,gmp,lz4,pcre}-devel \ lib{xslt,event,yaml,vpx,png,zip,icu,mcrypt,memcached,cap,dwarf}-devel \ {unixODBC,expat,mariadb}-devel lib{edit,curl,xml2,xslt}-devel \ glog-devel oniguruma-devel ocaml gperf enca libjpeg-turbo-devel openssl-devel \ mariadb mariadb-server {fastlz,double-conversion,re2}-devel make -y
Step 3. Installing HipHop Virtual Machine (HHVM) on CentOS 7.
Ok now we have the server ready lets get and build hhvm:
cd /tmp git clone https://github.com/facebook/hhvm -b master hhvm --recursive cd hhvm
Time to build:
cmake \ -DLIBMAGICKWAND_INCLUDE_DIRS="/usr/include/ImageMagick-6" \ -DLIBMAGICKCORE_LIBRARIES="/usr/lib64/libMagickCore-6.Q16.so" \ -DLIBMAGICKWAND_LIBRARIES="/usr/lib64/libMagickWand-6.Q16.so" .
make -j$(($(nproc)+1)) ./hphp/hhvm/hhvm --version sudo make install
Step 4. Config Setup HHVM.
First create some folders:
mkdir /etc/hhvm mkdir /var/run/hhvm mkdir /var/log/hhvm mkdir /var/tmp/hhvm mkdir -p /usr/share/hhvm/hdf/ chmod 775 /var/run/hhvm chmod 777 /var/tmp/hhvm
Next add some config files:
nano /etc/hhvm/server.hdf
Add following files:
PidFile = /var/run/hhvm/pid Server { Port = 9000 SourceRoot = /var/www/ DefaultDocument = index.php } Log { Level = Warning AlwaysLogUnhandledExceptions = true RuntimeErrorReportingLevel = 8191 UseLogFile = true UseSyslog = false File = /var/log/hhvm/error.log Access { * { File = /var/log/hhvm/access.log Format = %h %l %u % t \"%r\" %>s %b } } } Repo { Central { Path = /var/tmp/hhvm/.hhvm.hhbc } } #include "/usr/share/hhvm/hdf/static.mime-types.hdf" StaticFile { FilesMatch { * { pattern = .*\.(dll|exe) headers { * = Content-Disposition: attachment } } } Extensions : StaticMimeTypes } MySQL { TypedResults = false }
Next, Adding the service:
nano /usr/lib/systemd/system/hhvm.service
Add following files:
[Unit] Description=HHVM HipHop Virtual Machine (FCGI) [Service] ExecStart=/usr/local/bin/hhvm --config /etc/hhvm/server.hdf --user nobody --mode daemon -vServer.Type=fastcgi -vServer.Port=9000 [Install] WantedBy=multi-user.target
Reload the systemd service, start hhvm and add it to be started at boot time:
systemctl enable hhvm systemctl start hhvm systemctl status hhvm
Congratulation’s! You have successfully installed HipHop Virtual Machine. Thanks for using this tutorial for installing HipHop Virtual Machine (HHVM) on CentOS 7 systems. For additional help or useful information, we recommend you to check the official HHVM web site.