Debian: Compile and install multiple PHP CLI versions

# install dependencies
apt-get install -y build-essential

# download and compile PHP
for VERSION in 5.3.29 5.4.38 5.5.22 5.6.6; do
wget -q "http://de1.php.net/get/php-${VERSION}.tar.bz2/from/this/mirror" -O- | tar xj -C /tmp
cd /tmp/php-${VERSION}
./configure --prefix=/opt/php/${VERSION%.*} --disable-all --disable-cgi
make install -j5
done

# add to PATH
for i in /opt/php/*; do
ln -s $i/bin/php /usr/local/bin/php${i##*/}
done

# create backup
cd /opt/php
tar -cjf /tmp/opt.php.$(date -I).tar.bz2 *

# test backup
tar -tvf /tmp/opt.php.$(date -I).tar.bz2