Skip to content

Building and installing HHVM on Amazon Linux 2014.03

iansltx edited this page Dec 16, 2014 · 21 revisions

This process was tested against HHVM 3.3. Build with an m1.small instance at the smallest.


Dependencies

sudo yum -y update && \
sudo yum -y install \
	autoconf \
	automake \
	binutils-devel \
	boost-devel \
	bzip2-devel \
	chrpath \
	cmake \
	cpp \
	curl-devel \
	elfutils-libelf-devel \
	expat-devel \
	gcc-c++ \
	gd-devel \
	git \
	jemalloc-devel \
	libIDL-devel \
	libc-client-devel \
	libcap-devel \
	libevent-devel \
	libicu-devel \
	libmcrypt-devel \
	libmemcached-devel \
	libtool \
	libxml2-devel \
	make \
	memcached \
	mysql-devel \
	oniguruma-devel \
	openldap-devel \
	pam-devel \
	patch \
	pcre-devel \
	readline-devel \
	svn \
	wget \
	libxslt-devel \
	ImageMagick-devel \
;

CMake 3 is required for HHVM 3.4+ and isn't available in current Amazon Linux AMIs. You'll need to build CMake manually; see http://www.cmake.org/install/ for more information.

Checkout HHVM and submodules

cd ~ && \
git clone git://github.com/facebook/hhvm.git && \
cd hhvm && \
git checkout HHVM-3.3 && \
git submodule update --init --recursive && \
export CMAKE_PREFIX_PATH=`pwd`/.. && \
cd ..

Intel Thread Building Blocks (tbb) (4.0 or newer)

This build of Amazon Linux only has TBB 2.x available, so we need to compile a newer version from source. Known issues: #1568. Building on a t2.micro is quite slow, see issue #1362. It's suggested that we change our instance to a faster one (for example, a c3.8xlarge) temporarily to build TBB, then back to the t2.micro once completed.

wget https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb42_20130725oss_src.tgz && \
tar zxvf tbb42*.tgz && \
cd tbb42* && \
cd src && \
make && \
cd .. && \
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*/libtbb.so.2 /usr/lib64/ && \
sudo ln -s /usr/lib64/libtbb.so.2 /usr/lib64/libtbb.so && \
cd ..

libDwarf

git clone git://git.code.sf.net/p/libdwarf/code libdwarf && \
cd libdwarf/libdwarf && \
git checkout 2346f43f57f0ae768adffa55ea84b281d3aa71da && \
./configure && \
make && \
sudo cp libdwarf.a /usr/lib64/ && \
sudo cp libdwarf.h /usr/include/ && \
sudo cp dwarf.h /usr/include/ && \
cd ../..

Google glog

wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz && \
tar zxvf glog-0.3.3.tar.gz && \
svn checkout http://google-glog.googlecode.com/svn/trunk/ google-glog && \
cd google-glog && \
./configure --prefix=/usr && \
make && \
sudo make install && \
cd ..

Building HHVM

Refreshing library cache

sudo ldconfig

Compiling and installing

cd hhvm && \
cmake . && \
make && \
sudo make install

Alternatively compile with Zend Compat layer:

cd hhvm && \
cmake -DENABLE_ZEND_COMPAT=ON . && \
make && \
sudo make install

Updating HHVM (Nightly builds/master)

Do this if you would like to taste HHVM in its latest flavor. This will pull all updates from the master branch. This may have significant bugs & issues that are being worked on. Since the dependencies are already built, we just need to update and recompile HHVM itself.

cd ~/hhvm && \
git reset --hard HEAD && \
git checkout master && \
git pull --rebase origin && \
git submodule update --init --recursive && \
export CMAKE_PREFIX_PATH=`pwd`/.. && \
cmake . && \
make && \
sudo make install

Running HHVM on Amazon EC2

t1.micro

Because of its low memory, if you want to run HHVM on a t1.micro instance, you'll need to add the following to your config.hdf file (#1129):

Eval {
    JitASize = 134217728
    JitAStubsSize = 134217728
    JitGlobalDataSize = 67108864
}

Or the config.ini equivalent (not tested):

hhvm.eval.jit_a_size = 134217728
hhvm.eval.jit_a_stubs_size = 134217728
hhvm.eval.jit_global_data_size = 67108864

Beefier instance types don't have this issue, although it would still be a good idea to tweak your settings for your instance type.

Clone this wiki locally