Building and installing HHVM on CentOS 6.6

kaisung edited this page Jan 29, 2017 · 95 revisions


The following has been tested a few times and is working great afaik, if issues, feel free to tag @Sydney_o9 in the issue


  1. Install GCC Version 4.9.2
  2. Install Dependencies
  3. Get HHVM
  4. Install CMake
  5. Install Boost
  6. Install Google Glog
  7. Install Libmemcached
  8. Install JEMalloc
  9. Install SQLite
  10. MySQL
  11. Install TBB
  12. Install Libdwarf
  13. Install OCaml
  14. Install Image Magick
  15. Install HipHop

Appendix A. List of Dependencies for GCC
Appendix B. List of Dependencies for HHVM
Appendix C. Install HHVM & Hack Man Pages

1. Install GCC Version 4.9.2

We need to install a newer version of GCC as the version which comes with CentOS is too old.

1 Install Tools & Packages necessary for building GCC

sudo yum install gcc-c++ libgcc glibc-devel libgcc.i686 glibc-devel.i686 binutils gzip bzip2 make tar perl zip unzip wget

Note: Here we also installs 32-bit ('i386') C library and headers (`libgcc.i686` `glibc-devel.i686`). If you don't need to compile programs in 32-bits on your system, just configure with `--disable-multilib`

<kbd>2</kbd> Download GCC v4.9.2

cd /tmp && sudo wget -O gcc-current.tar.gz &&
sudo mkdir gcc-current && sudo tar -zxvf gcc-current.tar.gz -C /tmp/gcc-current --strip-components=1

<kbd>3</kbd> Download Support Libraries: GMP, MPFR, MPC, ISL, CLOOG


cd /tmp/gcc-current && sudo wget -O gmp-current.tar.bz2 &&
sudo mkdir gmp && sudo tar -jxvf gmp-current.tar.bz2 -C /tmp/gcc-current/gmp --strip-components=1


cd /tmp/gcc-current && sudo wget -O mpfr-current.tar.bz2 &&
sudo mkdir mpfr && sudo tar -jxvf mpfr-current.tar.bz2 -C /tmp/gcc-current/mpfr --strip-components=1


cd /tmp/gcc-current && sudo wget -O mpc-current.tar.gz &&
sudo mkdir mpc && sudo tar -zxvf mpc-current.tar.gz -C /tmp/gcc-current/mpc --strip-components=1


cd /tmp/gcc-current && sudo wget -O isl-current.tar.bz2 &&
sudo mkdir isl && sudo tar -jxvf isl-current.tar.bz2 -C /tmp/gcc-current/isl --strip-components=1


cd /tmp/gcc-current && sudo wget -O cloog-current.tar.gz &&
sudo mkdir cloog && sudo tar -zxvf cloog-current.tar.gz -C /tmp/gcc-current/cloog --strip-components=1

<kbd>4</kbd> Compile GCC

sudo mkdir /tmp/gcc-build && cd /tmp/gcc-build sudo ../gcc-current/configure --enable-languages=c,c++,fortran --enable-multilib --prefix=/usr/local/gcc sudo make sudo make install

<kbd>5</kbd> Move Old GCC and Replace With New Version

yum remove -y gcc gcc-c++ cpp

sudo mv /usr/bin/g++ /usr/bin/g++_old sudo mv /usr/bin/c++ /usr/bin/c++_old

sudo ln -s -f /usr/local/gcc/bin/gcc /usr/bin/gcc sudo ln -s -f /usr/local/gcc/bin/g++ /usr/bin/g++ sudo ln -s -f /usr/local/gcc/bin/c++ /usr/bin/c++ sudo ln -s -f /usr/local/gcc/bin/cpp /usr/bin/cpp sudo ln -s -f /usr/local/gcc/bin/gfortran /usr/bin/gfortran sudo ln -s -f /usr/local/gcc/bin/gcov /usr/bin/gcov

sudo cp /usr/local/gcc/lib64/ /usr/lib64/. sudo mv /usr/lib64/ /usr/lib64/ sudo ln -s -f /usr/lib64/ /usr/lib64/

## 2. Install Dependencies

sudo yum install epel-release -y sudo yum install -y -q git svn autoconf automake patch memcached cmake wget mysql-devel mysql-server 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 libxslt-devel libevent-devel libcurl-devel libmcrypt-devel tbb-devel ncurses-devel python-devel gperf gmp-devel

# Install libtool

cd /tmp &&
wget -O libtool-current.tar.gz > /dev/null 2>&1

mkdir libtool-current && tar -zxvf libtool-current.tar.gz -C /tmp/libtool-current --strip-components=1 > /dev/null 2>&1 &&
cd libtool-current

./configure && make && sudo make install

# Install Newer version of libcurl (Needed recent version for HHVM to compile properly - see [here](

rpm -Uvh yum install -y libcurl

## 3. Get HHVM

cd /usr/local sudo git clone git:// --depth=1 cd hhvm export CMAKE_PREFIX_PATH=/usr/local

## 4. Install CMake Version 3.0.2

Get CMake

cd /tmp &&
wget -O cmake-current.tar.gz

Untar CMake

mkdir cmake-current &&
tar -zxvf cmake-current.tar.gz -C /tmp/cmake-current --strip-components=1 &&
cd cmake-current

Install CMake

./configure --prefix=$CMAKE_PREFIX_PATH sed -i '1 s/$/-ltinfo/' Source/CMakeFiles/cmake.dir/link.txt make sudo make install

Export CMake Path for current session

export PATH=/usr/local/cmake/bin:$PATH

(Optional) Add CMake Path for following sessions (using Bash in this case)

sed -i '/export PATH/i PATH=$PATH:/usr/local/cmake/bin' ~/.bash_profile

## 5. Install Boost Version 1.58.0

Get Boost

cd /tmp &&
wget -O boost-current.tar.gz

Untar Boost

mkdir boost-current && tar -zxvf boost-current.tar.gz -C /tmp/boost-current --strip-components=1 &&
cd boost-current

Install Boost

sudo ./ --prefix=/usr/local/boost sudo ./b2 --layout=system install

Export Boost PATH for current session

export PATH=/usr/local/boost/include:$PATH export PATH=/usr/local/boost/lib:$PATH

(Optional) Add Boost Path for following sessions (using Bash in this case)

sed -i '/export PATH/i PATH=$PATH:/usr/local/boost/include' ~/.bash_profile sed -i '/export PATH/i PATH=$PATH:/usr/local/boost/lib' ~/.bash_profile

## 6. Install Google Glog Version 0.3.4

Get Google Glog

cd /tmp &&
wget -O glog-current.tar.gz

Untar Google Glog

mkdir glog-current && tar -zxvf glog-current.tar.gz -C /tmp/glog-current --strip-components=1 &&
cd glog-current

Install Google Glog

./configure --prefix=$CMAKE_PREFIX_PATH make sudo make install

## 7. Install Libmemcached Version 1.0.18

Get Libmemcached

cd /tmp &&
wget -O libmemcached-current.tar.gz

Untar Libmemcached

mkdir libmemcached-current && tar -zxvf libmemcached-current.tar.gz -C /tmp/libmemcached-current --strip-components=1 &&
cd libmemcached-current

Install Libmemcached

./configure --prefix=$CMAKE_PREFIX_PATH make sudo make install

## 8. Install JEMalloc Version 3.5.1

Get JEMalloc

cd /tmp &&
wget -O jemalloc-current.tar.gz

Untar JEMalloc

mkdir jemalloc-current && tar -xjvf jemalloc-current.tar.gz -C /tmp/jemalloc-current --strip-components=1 &&
cd jemalloc-current

Install JEMalloc

./configure --prefix=$CMAKE_PREFIX_PATH make sudo make install

## 9. Install SQLite

Get SQLite

cd /tmp &&
wget -O sqlite-current.tar.gz

Untar SQLite

mkdir sqlite-current && tar -zxvf sqlite-current.tar.gz -C /tmp/sqlite-current --strip-components=1 &&
cd sqlite-current

Install SQLite

./configure --prefix=$CMAKE_PREFIX_PATH make sudo make install

## 10. MySQL

Start MySQL

sudo service mysqld start

Start MySQL automatically on system startup

sudo chkconfig mysqld on

## 11. Install TBB (Threading Building Blocks)


cd /tmp &&
wget -O tbb-current.tar.gz

Untar TBB

mkdir tbb-current && tar -zxvf tbb-current.tar.gz -C /tmp/tbb-current --strip-components=1 &&
cd tbb-current

Install TBB


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.9.2_libc2.12_kernel2.6.32_release/ /usr/lib64/ sudo ln -s /usr/lib64/ /usr/lib64/

## 12. Install Libdwarf

Get Libdwarf

cd /tmp &&
wget -O libdwarf-current.tar.gz

Untar Libdwarf

mkdir libdwarf-current && tar -zxvf libdwarf-current.tar.gz -C /tmp/libdwarf-current --strip-components=1 &&
cd libdwarf-current

Install Libdwarf

./configure --prefix=$CMAKE_PREFIX_PATH make

sudo cp libdwarf/libdwarf.a /usr/lib64/ sudo cp libdwarf/libdwarf.h /usr/include/ sudo cp libdwarf/dwarf.h /usr/include/

## 13. Install OCaml

Get Ocaml

cd /tmp &&
wget -O ocaml-current.tar.gz

Untar OCaml

mkdir ocaml-current && tar -zxvf ocaml-current.tar.gz -C /tmp/ocaml-current --strip-components=1 &&
cd ocaml-current

Install OCaml (will install in /usr/local)

./configure sudo make world.opt sudo make install sudo make clean

Would be great to avoid that...

sudo ln -s /usr/local/bin/ocamlbuild /usr/bin/ocamlbuild sudo ln -s /usr/local/bin/ocamlopt /usr/bin/ocamlopt

## 14. Install Image Magick

Get Image Magick

cd /tmp &&
wget -O ImageMagick-current.tar.gz

mkdir ImageMagick-current && tar -zxvf ImageMagick-current.tar.gz -C /tmp/ImageMagick-current --strip-components=1 > /dev/null 2>&1 &&
cd ImageMagick-current

sudo mkdir -p /usr/local/imageMagick ./configure make sudo make install

## 15. Install HipHop

cd /usr/local/hhvm

For list of submodules, cat /usr/local/hhvm/.gitmodules

which leads to

sudo git submodule update --init --recursive sudo cmake . sudo sed -i -e 's/$/../../../lib/' hphp/hhvm/CMakeFiles/hhvm.dir/link.txt sudo make sudo make install

Export HHVM Path for current session

export PATH=/usr/local/hhvm/hphp/hhvm:$PATH

Add HHVM Path for following sessions (using Bash in this case)

sed -i '/export PATH/i PATH=$PATH:/usr/local/hhvm/hphp/hhvm' ~/.bash_profile

To make sure HHVM is installed and correctly in the path, run from terminal:

$ which hhvm
$ hhvm --version
HipHop VM 3.8.0-dev (rel)

Appendix A. List of Dependencies for GCC

Dependency Version Installation Type Needed For Links
gcc-c++ /// RPM GCC ///
libgcc /// RPM GCC ///
glibc-devel /// RPM GCC ///
libgcc.i686 /// RPM GCC ///
glibc-devel.i686 /// RPM GCC ///
binutils /// RPM GCC ///
gzip /// RPM GCC ///
bzip2 /// RPM GCC ///
make /// RPM GCC ///
tar /// RPM GCC ///
perl /// RPM GCC ///
zip /// RPM GCC ///
unzip /// RPM GCC ///
GMP 6.0.0 From Source GCC GMP Doc
MPFR 3.1.2 From Source GCC MPFR Doc
MPC 1.0.3 From Source GCC MPC Doc
ISL 0.12.2 From Source GCC ISL Doc
CLOOG 0.18.2 From Source GCC CLOOG Doc

Appendix B. List of Dependencies for HHVM

Dependency Version Installation Type Needed For Links
GCC (GNU Compiler Collection) 4.9.2 From Source HHVM Main Doc / Manuals / Prerequisites
git /// RPM HHVM ///
svn /// RPM HHVM ///
autoconf /// RPM HHVM ///
automake /// RPM HHVM ///
libtool /// RPM HHVM ///
patch /// RPM HHVM ///
memcached /// RPM HHVM ///
cmake /// RPM HHVM ///
wget /// RPM HHVM ///
mysql-devel /// RPM HHVM ///
mysql-server /// RPM HHVM ///
pcre-devel 8.20 RPM HHVM ///
gd-devel /// RPM HHVM ///
libxml2-devel /// RPM HHVM ///
expat-devel /// RPM HHVM ///
libicu-devel /// RPM HHVM ///
bzip2-devel /// RPM HHVM ///
oniguruma-devel /// RPM HHVM ///
openldap-devel /// RPM HHVM ///
readline-devel /// RPM HHVM ///
libc-client-devel /// RPM HHVM ///
libcap-devel /// RPM HHVM ///
binutils-devel /// RPM HHVM ///
pam-devel /// RPM HHVM ///
elfutils-libelf-devel /// RPM HHVM ///
libxslt-devel /// RPM HHVM ///
libevent-devel /// RPM HHVM ///
libcurl-devel /// RPM HHVM ///
libmcrypt-devel /// RPM HHVM ///
tbb-devel /// RPM HHVM ///
ncurses-devel /// RPM HHVM ///
python-devel /// RPM HHVM ///
gperf /// RPM HHVM ///
CMake 3.0.2 From Source HHVM Main Doc
Boost 1.58.0 From Source HHVM Main Doc
Google Glog 0.3.3 From Source HHVM Main Doc
Libmemcached 1.0.18 From Source HHVM Main Doc
JEMalloc 3.5.1 From Source HHVM Main Doc
SQLite /// From Source HHVM Main Doc
TBB (Threading Building Blocks) /// From Source HHVM Main Doc
Libdwarf /// From Source HHVM Main Doc
OCaml 4.01.0 From Source HHVM Main Doc / INSTALL
Image Magick /// From Source HHVM Main Doc

Appendix C. Install HHVM & Hack man pages

cd /usr/local/hhvm/hphp/doc/man && sudo mkdir man1
sudo find . -maxdepth 1 -type f -exec mv {} man1/ \;
sed -i '/export MANPATH/i MANPATH=$MANPATH:/usr/local/hhvm/hphp/doc/man' ~/.bash_profile

cd /usr/local/hhvm/hphp/hack/man && sudo mkdir man1
sudo find . -maxdepth 1 -type f -exec mv {} man1/ \;
sed -i '/export MANPATH/i MANPATH=$MANPATH:/usr/local/hhvm/hphp/hack/man' ~/.bash_profile

Source your .bash_profile (or whatever startup file your shell is using)

source ~/.bash_profile

You can now look up hhvm & other commands in your man pages normally

man hhvm
man hh-server
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.