In this tutorial, we will show you how to install HipHop Virtual Machine on your CentOS 7. For those of you who didn’t know, For those of you who didn’t know, 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.
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 account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the HipHop Virtual Machine (HHVM) on a CentOS 7 server.
Prerequisites
- A server running one of the following operating systems: CentOS 7.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
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 let’s 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 the 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 the 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
Congratulations! You have successfully installed the 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 check the official HHVM website.