Skip to content

Building and installing HHVM on CentOS 6.6

kaisung edited this page Jan 29, 2017 · 95 revisions

Note

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

Plan

  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 ftp://ftp.gnu.org/gnu/gcc/gcc-4.9.2/gcc-4.9.2.tar.gz -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

gmp

cd /tmp/gcc-current && sudo wget https://gmplib.org/download/gmp-6.0.0/gmp-6.0.0.tar.bz2 -O gmp-current.tar.bz2 &&
sudo mkdir gmp && sudo tar -jxvf gmp-current.tar.bz2 -C /tmp/gcc-current/gmp --strip-components=1

mpfr

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

mpc

cd /tmp/gcc-current && sudo wget http://www.multiprecision.org/mpc/download/mpc-1.0.3.tar.gz -O mpc-current.tar.gz &&
sudo mkdir mpc && sudo tar -zxvf mpc-current.tar.gz -C /tmp/gcc-current/mpc --strip-components=1

isl

cd /tmp/gcc-current && sudo wget ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/infrastructure/isl-0.12.2.tar.bz2 -O isl-current.tar.bz2 &&
sudo mkdir isl && sudo tar -jxvf isl-current.tar.bz2 -C /tmp/gcc-current/isl --strip-components=1

cloog

cd /tmp/gcc-current && sudo wget http://bastoul.net/cloog/pages/download/cloog-0.18.2.tar.gz -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/libstdc++.so.6.0.20 /usr/lib64/. sudo mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak sudo ln -s -f /usr/lib64/libstdc++.so.6.0.20 /usr/lib64/libstdc++.so.6


## 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 http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz -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](https://github.com/facebook/hhvm/issues/5850))

rpm -Uvh http://www.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-1-13.rhel6.noarch.rpm yum install -y libcurl

## 3. Get HHVM

cd /usr/local sudo git clone git://github.com/facebook/hhvm.git --depth=1 cd hhvm export CMAKE_PREFIX_PATH=/usr/local


## 4. Install CMake Version 3.0.2

Get CMake

cd /tmp &&
wget http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz -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 http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.gz/download -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 ./bootstrap.sh --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 https://github.com/google/glog/archive/v0.3.4.tar.gz -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 http://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz -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 http://www.canonware.com/download/jemalloc/jemalloc-3.5.1.tar.bz2 -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 http://ftp.osuosl.org/pub/blfs/conglomeration/sqlite/sqlite-autoconf-3071502.tar.gz -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)

Get TBB

cd /tmp &&
wget http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20120613oss_src.tgz -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

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 cp build/linux_intel64_gcc_cc4.9.2_libc2.12_kernel2.6.32_release/libtbb.so.2 /usr/lib64/ sudo ln -s /usr/lib64/libtbb.so.2 /usr/lib64/libtbb.so


## 12. Install Libdwarf

Get Libdwarf

cd /tmp &&
wget http://www.prevanders.net/libdwarf-20140413.tar.gz -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 http://caml.inria.fr/pub/distrib/ocaml-4.01/ocaml-4.01.0.tar.gz -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

cd /tmp &&
wget http://www.imagemagick.org/download/ImageMagick.tar.gz -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

sudo git submodule update --init --recursive sudo cmake . sudo sed -i -e 's/$/../../../lib/libmemcached.so/g' 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
/usr/local/hhvm/hphp/hhvm/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