Php HHVM (aka the HipHop Virtual Machine) on Centos 7

To get my php projects running as fast as possible om trying to use hhvm.
And here is my small guide how to install it on centos 7

I used the docs from https://github.com/facebook/hhvm/wiki/Building-and-installing-hhvm-on-CentOS-7.x

 

1. First setup you centos linux host

 

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++ cmake git psmisc {binutils,boost,jemalloc}-devel \
{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 inotify-tools-devel ocaml
yum install ImageMagick-last\* --enablerepo=remi

My box is a clean centos 7. If you have ImageMagic install already uninstall it.

 

2. Ok now we have the server ready lets get and build hhvm

 

cd /opt
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

 

 

 

3. Config setup

 

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

Now add some config files

vi /etc/hhvm/server.hdf
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
}

and the file

vi /usr/share/hhvm/hdf/static.mime-types.hdf

I added this file https://github.com/hhvm/packaging/blob/master/hhvm/rpm/fedora20/rpmbuild/SOURCES/static.mime-types.hdf

 

 

Adding the service

vi /usr/lib/systemd/system/hhvm.service
[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

Enable and start

systemctl enable hhvm
systemctl start hhvm
systemctl status hhvm

Error if not started i had some trying with dirs and permissions test chmod 777 to the dirs and then when it works start tight the perms

tail /var/log/hhvm/error.log

  5 comments for “Php HHVM (aka the HipHop Virtual Machine) on Centos 7

  1. Matthew
    October 7, 2015 at 3:49 am

    Nice guide, having an error though.. weird one, since OpenSSL is installed.. centos 7 minimal fully updated

    CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
    Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
    system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES
    OPENSSL_INCLUDE_DIR)

    • Matthew
      October 7, 2015 at 3:58 am

      Didn’t have openssl-devel installed.

  2. Matthew
    October 7, 2015 at 4:41 am

    another error on start and no log file set?

    tail /var/log/hhvm/error.log
    tail: cannot open ‘/var/log/hhvm/error.log’ for reading: No such file or directory

    systemctl status hhvm
    hhvm.service – HHVM HipHop Virtual Machine (FCGI)
    Loaded: loaded (/usr/lib/systemd/system/hhvm.service; enabled)
    Active: failed (Result: exit-code) since Tue 2015-10-06 20:39:55 MDT; 4s ago
    Process: 13056 ExecStart=/usr/local/bin/hhvm –config /etc/hhvm/server.hdf –user nobody –mode daemon -vServer.Type=fastcgi -vServer.Port=9000 (code=exited, status=255)
    Main PID: 13056 (code=exited, status=255)

    Oct 06 20:39:55 nginx-test-01.ilike.beer systemd[1]: Started HHVM HipHop Virtual Machine (FCGI).
    Oct 06 20:39:55 nginx-test-01.ilike.beer hhvm[13056]: Uncaught exception: NotFoundError: File /usr/share/hhvm/hdf/static.mime-types.hdf not found\n
    Oct 06 20:39:55 nginx-test-01.ilike.beer systemd[1]: hhvm.service: main process exited, code=exited, status=255/n/a
    Oct 06 20:39:55 nginx-test-01.ilike.beer systemd[1]: Unit hhvm.service entered failed state.

    • October 7, 2015 at 9:22 am

      Hi

      Sorry for late response I will try it my self it can be that some update has come and i havet update the post.
      Ping a comment when i updated the post.

      // Matte

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: