Installation from source code is not difficult but I want to share how to do it with older php version on Ubuntu 14.04
First of all we need to get php source code and extract it into some directory
mkdir -p ~/Downloads/php-5.3.12
cd ~/Downloads/php-5.3.12
wget http://museum.php.net/php5/php-5.3.12.tar.gz
tar zxf php-5.3.12.tar.gz
cd php-5.3.12
After that we must install some libraries:
apt-get install libxml2-dev
apt-get install libpcre3-dev
apt-get install libbz2-dev
apt-get install libdb4.8-dev
apt-get install libjpeg-dev
apt-get install libpng12-dev
apt-get install libxpm-dev
apt-get install libfreetype6-dev
apt-get install libt1-dev
apt-get install libgd2-xpm-dev
apt-get install libgmp-dev
apt-get install libmysqlclient-dev
apt-get install libmhash-dev
apt-get install unixodbc-dev
apt-get install freetds-dev
apt-get install libpspell-dev
apt-get install libsnmp-dev
apt-get install libtidy-dev
apt-get install libxslt1-dev
apt-get install libmcrypt-dev
And of course
apt-get install make
After that we create Makefile. In this case we will install php in
/usr/share/php5.3.12
./configure \
--prefix=/usr/share/php5.3.12 \
--datadir=/usr/share/php5.3.12 \
--mandir=/usr/share/man \
--bindir=/usr/bin/php5.3.12 \
--with-libdir=lib64 \
--includedir=/usr/include \
--sysconfdir=/etc/php5.3.12/ \
--with-config-file-path=/etc/php5.3.12/cli \
--with-config-file-scan-dir=/etc/php5.3.12/conf.d \
--localstatedir=/var \
--disable-debug \
--with-regex=php \
--disable-rpath \
--disable-static \
--disable-posix \
--with-pic \
--with-layout=GNU \
--with-pear=/usr/share/php \
--enable-calendar \
--enable-sysvsem \
--enable-sysvshm \
--enable-sysvmsg \
--enable-bcmath \
--with-bz2 \
--enable-ctype \
--with-db4 \
--without-gdbm \
--with-iconv \
--enable-exif \
--enable-ftp \
--enable-cli \
--with-gettext \
--enable-mbstring \
--with-pcre-regex=/usr \
--enable-shmop \
--enable-sockets \
--enable-wddx \
--with-libxml-dir=/usr \
--with-zlib \
--with-kerberos=/usr \
--with-openssl=/usr \
--enable-soap \
--enable-zip \
--with-mhash \
--with-exec-dir=/usr/lib/php5/libexec \
--without-mm \
--with-curl=shared,/usr \
--with-zlib-dir=/usr \
--with-gd=shared,/usr \
--enable-gd-native-ttf \
--with-gmp=shared,/usr \
--with-jpeg-dir=shared,/usr \
--with-xpm-dir=shared,/usr/X11R6 \
--with-png-dir=shared,/usr \
--with-freetype-dir=shared,/usr \
--with-ttf=shared,/usr \
--with-t1lib=shared,/usr \
--with-ldap=shared,/usr \
--with-mysql=shared,/usr \
--with-mysqli=shared,/usr/bin/mysql_config \
--with-pspell=shared,/usr \
--with-unixODBC=shared,/usr \
--with-xsl=shared,/usr \
--with-snmp=shared,/usr \
--with-sqlite=shared,/usr \
--with-tidy=shared,/usr \
--with-xmlrpc=shared \
--enable-pdo=shared \
--without-pdo-dblib \
--with-pdo-mysql=shared,/usr \
--with-pdo-odbc=shared,unixODBC,/usr \
--with-pdo-dblib=shared,/usr \
--enable-force-cgi-redirect --enable-fastcgi \
--with-libdir=/lib/x86_64-linux-gnu \
--with-pdo-sqlite=shared \
--with-sqlite=shared \
--with-libdir=/lib/x86_64-linux-gnu \
--enable-ipv6 \
--enable-fpm \
--with-mcrypt \
--with-imap-ssl
After that
make && make install
Result must be this: