In one of my previous articles I described the installation process of HipHop for PHP compiler on Fedora system.
I’ve also mentioned that CentOS 5.5 had problems with this compiler.
In this article I’m going to show you how to overcome these difficulties and succesfully install HipHop for PHP on this system.
Where can I find CentOS?
The system is available here (ISO image).
How can I install it?
In the beginning you must attach an additional EPEL repository (the path may differ on your system) and install the missing packets using yum command:
rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm yum -y install git cmake pcre-devel libmcrypt-devel mysql-devel gd-devel libxml2-devel libcap-devel binutils-devel flex bison expat-devel patch gcc44 gcc44-c++ gcc gcc-c++ bzip2 bzip2-devel memcached openldap openldap-devel readline-devel libc-client-devel pam-devel wget ncurses-devel
Then create a project directory and put a cloned HipHop for PHP with git repository there:
mkdir hiphop cd hiphop git clone git://github.com/facebook/hiphop-php.git
And now you must download and extract additional libraries that weren’t added using yum command. We need their specific versions:
wget "http://downloads.sourceforge.net/project/re2c/re2c/0.13.5/re2c-0.13.5.tar.gz?use_mirror=cdnetworks-us-2" wget "http://www.threadingbuildingblocks.org/uploads/77/142/2.2/tbb22_20090809oss_src.tgz" wget http://curl.haxx.se/download/curl-7.20.0.tar.bz2 wget http://www.monkey.org/~provos/libevent-1.4.14-stable.tar.gz wget http://launchpad.net/libmemcached/1.0/0.48/+download/libmemcached-0.48.tar.gz wget http://download.icu-project.org/files/icu4c/4.6.1/icu4c-4_6_1-src.tgz wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.2.tar.gz wget "http://downloads.sourceforge.net/project/boost/boost/1.46.1/boost_1_46_1.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fboost%2Ffiles%2Fboost%2F1.46.1%2F&use_mirror=ignum" wget http://php.webtutor.pl/wp-content/uploads/2011/04/libcclient2007-devel.tar.gz tar xvjf curl-7.20.0.tar.bz2 tar xvzf libevent-1.4.14-stable.tar.gz tar xvzf re2c-0.13.5.tar.gz tar xvzf tbb22_20090809oss_src.tgz tar xvzf libmemcached-0.48.tar.gz tar xvzf icu4c-4_6_1-src.tgz tar xvzf onig-5.9.2.tar.gz tar xvzf boost_1_46_1.tar.gz tar xvzf libcclient2007-devel.tar.gz
After you’ve extracted these libraries, you must update them with patches provided by Facebook and then compile them into the project directory (this way you won’t override CentOS’ system libraries). In order to do this you have to use the GCC 4.4+ compiler (older versions are unsupported):
export CC=gcc44 export CMAKE_PREFIX_PATH=`pwd`/local cd tbb22_20090809oss gmake cp -Rp include/tbb/ /usr/include/ cp `pwd`/build/*_release/*.so /usr/lib/ cp `pwd`/build/*_release/*.so.2 /usr/lib/ ldconfig cd .. cd re2c-0.13.5 ./configure --prefix=`pwd`/../local make install cd .. cd libevent-1.4.14-stable cp ../hiphop-php/src/third_party/libevent-1.4.14.fb-changes.diff . patch < libevent-1.4.14.fb-changes.diff ./configure --prefix=`pwd`/../local make install cd .. cd curl-7.20.0 cp ../hiphop-php/src/third_party/libcurl.fb-changes.diff . patch -p1 < libcurl.fb-changes.diff ./configure --prefix=`pwd`/../local make install cd .. cd libmemcached-0.48 ./configure --prefix=`pwd`/../local make install cd .. cd icu/source ./configure --prefix=`pwd`/../../local make install cd ../.. cd onig-5.9.2 ./configure --prefix=`pwd`/../local make install cd .. cd boost_1_46_1 ./bootstrap.sh --prefix=../local --libdir=../local/lib ./bjam --layout=system install export Boost_LIBRARYDIR=../local/include/boost/ cd .. cp -r imap local/include/ cp /usr/lib/libc-client.so.2007 local/lib/libc-client.so
Now it’s time to compile the HipHop for PHP itself.
cd hiphop-php git submodule init git submodule update export HPHP_HOME=`pwd` export HPHP_LIB=`pwd`/bin cmake . make
The installation process on the CentOS system is far more complex than the installation on Fedora. Many libraries had to be compiled manually because they weren’t in EPEL/CentOS repository or were outdated.
You should remember that HipHop for PHP was created to work only on 64-bit systems. Although the support for i386 architecture has to some extent been implemented, it’s still an experimental feature and doesn’t guarantee the stable operation of PHP scripts.
*** Thanks to Piotr Graniszewski for English translation ***