Build HHVM on Centos7
While building HHVM (HipHop Virtual Machine) for faster PHP on CentOS 6.x was pretty much a nightmare because almost none of third-party libraries are available from major repositories, the freshly released CentOS 7.0 solves most of this problem as it has far newer packages available from EPEL (because it has roots in modern Fedora 19).
Note that unlike PHP/PHPNG, HHVM requires major resources to build. You may be used to making PHP in 15 minutes on a little old 256mb 1ghz box. You can forget that with HHVM which is a beast to compile. 1.5-2mb ram and lots of cpu power required to keep it an hour or two (this is part of why PHP NG instead is so exciting because it will be so much easier to custom build).
I will assume you have CentOS 7.0 setup and know how to work in bash as root. Make sure you have either the default MariaDB or MySQL installed for the libraries.
You will need to setup the EPEL repository in yum. Currently they consider 7.x support to be “beta” but the “/beta/” part of the url could be removed anytime soon.
cd /tmp wget http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm yum install epel-release-7-0.2.noarch.rpm
Then you need the new 4.8 compiling tools (no more devtoolset needed like CentOS 6.x) cmake 2.8 as well as git if you don’t already have them installed.
yum install gcc gcc-c++ cmake git
Now you need a whole bunch of library dependencies, I think I found them all.
yum install binutils-devel boost-devel libmemcached-devel jemalloc-devel libevent-devel libxslt-devel libicu-devel tbb-devel libzip-devel bzip2-devel openldap-devel readline-devel elfutils-libelf-devel libdwarf-devel libcap-devel libyaml-devel libedit-devel unixODBC-devel ImageMagick-devel
typically installing the “devel” package will also install the parent package)
There are two packages left, google-glog and oniguruma , that CentOS 7.0 does not have in the main or EPEL repositories at this time unfortunately. However this is still far better than 6.x (which strangely does actually have oniguruma). So we have to build them ourselves.
cd /tmp wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz tar xvzf glog-0.3.3.tar.gz cd glog-0.3.3 ./configure make make install
cd /tmp wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.5.tar.gz tar xvzf onig-5.9.5.tar.gz cd onig-5.9.5 ./configure make make install
Now we are ready to pull down the huge source code for HHVM and all of its bundled third-party libraries.
I ran into a problem when trying to checkout the 3.2 branch where it is tied to an older libzip version 0.10 which does not work with 3.2 and requires 0.11 – this specific fix was still not applied to the 3.2 branch so unless that changes by the time you read this, you need to checkout the master instead.
cd /tmp git clone https://github.com/facebook/hhvm -b master hhvm --recursive
(change -b master to -b HHVM-3.2 if they eventually fix 3.2 branch)
Now we are ready to start the build. First do your configure and see if everything passes or if something was missed.
cd /tmp/hhvm ./configure
If it looks good, start the compile and go do something for an hour or two. If you have a multi-core machine with plenty of ram, you can try to accelerate make by telling it you have extra cores (didn’t seem to work for me).
Make # make -j4 (where 4 is the number of cores you have)
You can try to find other hints, tips and tricks at the HHVM wiki on github .
Hope that helps. Enjoy and let me know if I forgot anything.
以上为官方提供,我照搬,下面为实际安装过程当中遇到的问题,以及解决办法。
1、Cannot find Mysql.
Yum install -y mariadb mariadb-devel mariadb-common mariadb-server
2、Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)
yum install curl-devel
3、Could NOT find EXPAT (missing: EXPAT_LIBRARY EXPAT_INCLUDE_DIR)
yum -y install expat-devel
4、Could NOT find mcrypt library.
yum -y install libmcrypt libmcrypt-devel
5、Could NOT found llvm-config
OCaml not found
Could NOT find LibPng
Could NOT find LibVPX
Could NOT find GMP
Yum install ocalm libpng-devel libvpx-devel gmp-devel llvm-devel -y
HHVM启动命令 hhvm -m daemon -vServer.Type=fastcgi -c /etc/hhvm.hdf
hhvm.hdf的内容为
Server { Port = 9000 SourceRoot = /datafile1/www/html #Type value:fastcgi|libevent Type=fastcgi } Eval { Jit = true } Log { Level = Error UseLogFile = true File = /tmp/hhvm/error.log Access { * { File = /tmp/hhvm/access.log Format = %h %l %u %t \"%r\" %>s %b } } } VirtualHost { * { Pattern = .* RewriteRules { dirindex { pattern = ^(.*)/$ to = $1/index.php qsa = true } } } } StaticFile { FilesMatch { * { pattern = .*\.(dll|exe) headers { * = Content-Disposition: attachment } } } Extensions { css = text/css gif = image/gif html = text/html jpe = image/jpeg jpeg = image/jpeg jpg = image/jpeg png = image/png tif = image/tiff tiff = image/tiff txt = text/plain } }