PHP: Installing HipHop PHP on Ubuntu
A couple of weeks ago, a blog post came across /r/php titled Wow HHVM is fast…too bad it doesn’t run my code. The post is pretty interesting, it takes a look at what the test pass % is for a variety of PHP frameworks and applications. This post was actually the first time I’d heard an update about HipHop in awhile so I was naturally curious to see how the project had evolved in the last year or so.
Turns out, the project has undergone a major overhaul and is well on its way to achieving production feature parity against the Zend PHP implementation. Anyway, I decided to give installing HipHop a shot and unfortunately their installation guide seems to be a bit out of date so here’s how you do it.
Quickstart
To keep things simple, I used a 64-bit Ubuntu 13.04 AMI (https://console.aws.amazon.com/ec2/home?region=us-east-1#launchAmi=ami-e1357b88) on a small EC2. One thing to note is that HipHop will only work on 64-bit machines right now.
Once you have the EC2 running, Facebook’s instructions on GitHub are mostly accurate except that you’ll need to manually install libunwind.
# Get all the pre-reqs installed:
sudo apt-get install git-core cmake g++ libboost-dev libmysqlclient-dev \
libxml2-dev libmcrypt-dev libicu-dev openssl build-essential binutils-dev \
libcap-dev libgd2-xpm-dev zlib1g-dev libtbb-dev libonig-dev libpcre3-dev \
autoconf libtool libcurl4-openssl-dev libboost-system-dev \
libboost-program-options-dev libboost-filesystem-dev wget memcached \
libreadline-dev libncurses-dev libmemcached-dev libbz2-dev \
libc-client2007e-dev php5-mcrypt php5-imagick libgoogle-perftools-dev \
libelf-dev libdwarf-dev subversion \
libboost-regex-dev libcurl4-openssl-dev libgoogle-glog-dev libjemalloc-dev
# Get the HipHop code
mkdir dev
cd dev
export CMAKE_PREFIX_PATH=`pwd`
git clone git://github.com/facebook/hiphop-php.git
# Get libevent and build it
git clone git://github.com/libevent/libevent.git
cd libevent
git checkout release-1.4.14b-stable
cat ../hiphop-php/hphp/third_party/libevent-1.4.14.fb-changes.diff | patch -p1
./autogen.sh
./configure --prefix=$CMAKE_PREFIX_PATH
make
make install
cd ..
# Get libunwind and build it
# NOTE: You need to set a CFLAGS option or you'll hit an error - http://comments.gmane.org/gmane.comp.lib.unwind.devel/1133
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.0.1.tar.gz
tar -zxvf libunwind-1.0.1.tar.gz
cd libunwind-1.0.1/
export CFLAGS="-U_FORTIFY_SOURCE"
./configure --prefix=$CMAKE_PREFIX_PATH
make
make install
cd ..
# Build HipHop
# NOTE: This takes a loooong time on a small EC2
cd hiphop-php
rm CMakeCache.txt
export HPHP_HOME=`pwd`
cmake .
make
After that, you can test it out by running:
ubuntu@ip-10-60-47-153:~/dev/hiphop-php$ ./hphp/hhvm/hhvm -m server -p 8080
mapping self...
mapping self took 0'00" (6052 us) wall time
loading static content...
searching all files under source root...
analyzing 29483 files under source root...
loaded 0 bytes of static content in total
loading static content took 0'00" (363272 us) wall time
page server started
all servers started
Awesome, you have HipHop running. Now just how fast is it?
Well you’ll have to check back for part 2…
Questions or comments about this? Email us at contact@setfive.com.