Building and installing HHVM on CentOS 6.3

sherlockhua edited this page Jan 26, 2015 · 62 revisions
Clone this wiki locally

(This page is a work in progress. Instructions are for building the HipHop VM, or HHVM for CentOS 6.3 64bit. The instructions will also apply to Fedora 19.)

WARNING: Instructions are out of date. hhvm now requires gcc 4.8. Read Building-and-installing-hhvm-on-centos-6.x instead.

If your build environment does not have internet access, You could refer to this to build your hhvm in centos6.3 by scripts:

Packages installation

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 libxslt-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 elfutils-libelf-devel-static ImageMagick-devel libevent-devel
  • note: ImageMagick version 5.7+ is needed. you can get a more recent version from remi:
yum install ImageMagick-last* --enablerepo=remi


Although CentOS doesn't provide libmcrypt, we can borrow from EPEL and get the files we need.

rpm -ivh
yum install libmcrypt-devel

Installing GCC 4.7

The version of GCC which comes with CentOS is too old for the C++11 features used by HipHop. Either find another RPM from a nearby distro. Hip-Hop requires GCC min version 4.7

1. build & install gmp:


tar jxf gmp-5.1.3.tar.bz2 && cd gmp-5.1.3/

./configure --prefix=/usr/local/gmp

make && make install

cd ..

2. build & install mpfr:


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 ..

3. build & install mpc:


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 ..

After build & install these libs, you could start to build & Install gcc4.7.3:

4. build & install gcc 4.7.3


tar jxf gcc-4.7.3.tar.bz2 ;cd gcc-4.7.3

./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/


[ $? -eq 0 ];then

echo "this gcc configure is success"


echo "this gcc configure is failed"


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/

make && make install

[ $? -eq 0 ] && echo install success

5. set up the gcc env:

vi /etc/

Paste the following lines


Reload Config


Move Old GCC and Replace With New Version

mv /usr/bin/gcc  /usr/bin/gcc_old

mv /usr/bin/g++  /usr/bin/g++_old

mv /usr/bin/c++ /usr/bin/c++_old

ln -s -f /usr/local/gcc/bin/gcc  /usr/bin/gcc

ln -s -f /usr/local/gcc/bin/g++  /usr/bin/g++

ln -s -f /usr/local/gcc/bin/c++ /usr/bin/c++

cp /usr/local/gcc/lib64/ /usr/lib64/.

mv /usr/lib64/ /usr/lib64/

ln -s -f /usr/lib64/ /usr/lib64/

6. finished.

you could run gcc --version to check if the current gcc version is gcc4.7.3, and also need to check g++, to see if the version is changed to g++4.7.3 too.

Installing CMake

The version of CMake which comes with CentOS6.3 is too old for the latest HHVM which requires CMake version >= 2.8.7. Either find another RPM from a nearby distro, or try using @jackywei's instructions for installing CMake from

(This does not apply to Fedora 19.)

Getting HipHop source-code

git clone --depth=1
cd hhvm
#export CMAKE_PREFIX_PATH=`pwd`/../usr
cd ..

Building third-party libraries


Make sure that your system time is correct, otherwise ./configure will fail.

git clone git:// --depth=1
cd curl
./configure --prefix=$CMAKE_PREFIX_PATH
sudo make install
cd ..

Note: If you're building a version of cURL older than 7.28.0 (for whatever reason), you'll need to apply the patch in third-party to update it prior to the make step.

cat ../hhvm/third-party/libcurl-7.22.1.fb-changes.diff | patch -p1

Google glog

svn checkout google-glog
cd google-glog
./configure --prefix=$CMAKE_PREFIX_PATH
sudo make install
cd ..


There may be issues with 1.0.17 and your version of centos. If so, use 1.0.16

tar -xzvf libmemcached-1.0.17.tar.gz
cd libmemcached-1.0.17
./configure --prefix=$CMAKE_PREFIX_PATH
sudo make install
cd ..

JEMalloc 3.0

tar xjvf jemalloc-3.5.1.tar.bz2
cd jemalloc-3.5.1
./configure --prefix=$CMAKE_PREFIX_PATH
sudo make install
cd ..

tbb and libdwarf

As of this writing, libdwarf is not available with CentOS 6.3, and the version of libtbb is much too old. Both these packages also suffer the problem of not having install targets, so getting them on your system is a bit more cumbersome.


wget ''
tar -zxf tbb40_20120613oss_src.tgz
cd tbb40_20120613oss

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 cp build/linux_intel64_gcc_cc4.7.3_libc2.12_kernel2.6.32_release/ /usr/lib64/
sudo ln -s /usr/lib64/ /usr/lib64/
cd ..

The exact path to your generated may be slightly different depending on your version of gcc, libc, and the kernel, but that should be close.


wget ''
tar xzvf libdwarf-20140413.tar.gz
cd libdwarf/libdwarf
sudo cp libdwarf.a /usr/lib64/
sudo cp libdwarf.h /usr/include/
sudo cp dwarf.h /usr/include/
cd ../..

Note: You may need to check out c6a2ce4cc11ef16c53a19e9fd6c2685f189ac709^ and ensure that elfutils-libelf-devel is installed.

Refreshing library cache


Building HipHop

cd hhvm
git submodule update --init --recursive
cmake .

Running programs

The hhvm binary can be found in hphp/hhvm/hhvm.

The Hack language



If any errors occur, it may be required to remove the CMakeCache.txt directory in the checkout.

If your failure was on the make command, try to correct the error and run make again, it should restart from the point it stops. If don't, try to remove as explained above.

If cmake or make are unable to find/compile the Imagick extension, use this gist:

If you met some issues on build, You could also try to upgrade your Boost to 1.50 version and GCC to 4.6.1 version: You could follow this instruction for build BOOST: