HHVM, the HipHop Virtual Machine created by Facebook is pretty cool, bringing C like performance and scale-ability to the PHP crowd. PHP certainly is not my favorite language but if you need something deployed on a generic platform quickly and network accessible, PHP is a good starting point.
There are a number of good resources on the net for this, but like all the posts here they are notes for myself and what worked for me.
Get the required packages for compilation:
sudo yum install git svn cpp make autoconf automake libtool patch memcached gcc-c++ cmake wget boost-devel mysql-devel pcre-devel gd-devel libxml2-devel expat-devel libicu-devel bzip2-devel oniguruma-devel openldap-devel readline-devel libc-client-devel libcap-devel binutils-devel pam-devel elfutils-libelf-devel
For CentOS there are a couple libraries that are too old for HHVM, and we have to compile/install them first. Like libmcrypt, we need the development library as well:
cd ~/dev wget 'http://pkgs.repoforge.org/libmcrypt/libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpm' wget 'http://pkgs.repoforge.org/libmcrypt/libmcrypt-2.5.7-1.2.el6.rf.x86_64.rpm' rpm -Uhv libmcrypt-*.rpm
and GMP:
wget https://gmplib.org/download/gmp/gmp-5.1.3.tar.bz2 tar jxf gmp-5.1.3.tar.bz2 && cd gmp-5.1.3/ ./configure --prefix=/usr/local/gmp make && make install cd ..
and mpfr:
wget http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2 tar jxf mpfr-3.1.2.tar.bz2 ;cd mpfr-3.1.2/ ./configure --prefix=/usr/local/mpfr -with-gmp=/usr/local/gmp make && make install cd ..
and mpc:
wget http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz tar xzf mpc-1.0.1.tar.gz ;cd mpc-1.0.1 ./configure --prefix=/usr/local/mpc -with-mpfr=/usr/local/mpfr -with-gmp=/usr/local/gmp make &&make install cd ..
make sure you have ncurses and ncurses-devel:
sudo yum install ncurses-devel
now build the cmake utility:
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz tar -xvzf cmake-2.8.12.1.tar.gz cd cmake-2.8.12.1 ./configure make sudo make install
Google Glog, for this we are going to need libcurl which is not mentioned in the docs:
sudo yum install libcurl
now glog:
svn checkout http://google-glog.googlecode.com/svn/trunk/ google-glog cd google-glog/ ./configure --prefix=/usr make sudo make install
Now we need jemalloc:
wget http://www.canonware.com/download/jemalloc/jemalloc-3.0.0.tar.bz2 tar -xvzf jemalloc-3.0.0.tar.bz2 cd jemalloc-3.0.0 ./configure --prefix=/usr make sudo make install
libmemcached, I was already running a Memcache serer under a few services, so for me I had to un-install and rebuild:
wget https://launchpad.net/libmemcached/1.0/1.0.17/+download/libmemcached-1.0.17.tar.gz tar -xvzf libmemcached-1.0.17.tar.gz cd libmemcached-1.0.17 ./configure --prefix=/usr make sudo service memcached stop sudo yum remove libmemcached sudo make install cd ..
Now tbb, NOTE – Centos 6.3 does have tbb available but again it’s not recent enough so avoid the temptation to yum it. I also had to make some adjsutments to the install process, though this might be avoided with a more specific set of config flags:
wget 'http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20120613oss_src.tgz' tar -xvzf tbb40_20120613oss_src.tgz cd tbb40_20120613oss make sudo mkdir -p /usr/include/serial sudo cp -a include/serial/* /usr/include/serial/ sudo mkdir -p /usr/include/tbb sudo cp -a include/tbb/* /usr/include/tbb/ sudo make install sudo cp build/linux_intel64_gcc_cc4.7.3_libc2.12_kernel2.6.32_release/libtbb.so.2 /usr/lib64/ sudo ln -s /usr/lib64/libtbb.so.2 /usr/lib64/libtbb.so
libdwarf, I got lazy here and yum’d it and it worked, so moving on:
sudo yum install libdwarf libdwarf-tools libdwarf-devel
now boost, this one also took a while. Make sure you have python and related devel libs installed:
wget http://downloads.sourceforge.net/project/boost/boost/1.50.0/boost_1_50_0.tar.bz2 tar -xvjf boost_1_50_0.tar.bz2 cd boost_1_50_0 ./bootstrap.sh --prefix=/usr --libdir=/usr/lib ./bjam --layout=system install sudo ./bjam --layout=system install
and finally, GCC. this one takes a awhile, so find something to do. I actually used the newest version of GCC from http://gcc.gnu.org/releases.html which requires a newer version of the cmake utility::
wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.7.3.tar.bz2 tar jxf gcc-4.8.2.tar.bz2 ;cd gcc-4.8.2 ./configure --prefix=/usr/local/gcc -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ -with-gmp=/usr/local/gmp -with-mpfr=/usr/local/mpfr/ -with-mpc=/usr/local/mpc/
this compile line worked better for me on a seemingliy identical Centos image:
./configure --prefix=/usr --with-libdir=lib64 --with-gmp=/usr/lib64 --with-mpfr=/usr/lib64 --with-mpc=/usr/lib64
Now we are ready for HHVM. this is a large download even through GIT:
git clone git://github.com/facebook/hhvm.git cd hhvm export CMAKE_PREFIX_PATH=/usr export CMAKE_PREFIX_PATH=`pwd`/../usr export HPHP_HOME=`pwd`
Build HHVM:
git submodule init git submodule update --recursive export HPHP_HOME=`pwd` cmake . make
If this works, you’re home. Check your install with the version command:
hhvm --version