Make sure you update the package index.
sudo apt-get update
Install dependency package before building.
sudo apt-get install \
checkinstall \
apache2-dev \
libreadline-dev \
libmcrypt-dev \
libxml2-dev \
libcurl4-openssl-dev \
libjpeg-dev \
libpng-dev \
libxpm-dev \
libbz2-dev \
libmysqlclient-dev \
libpq-dev \
libicu-dev \
libfreetype6-dev \
libldap2-dev \
libxslt-dev \
libssl-dev \
libldb-dev
Create symbolic link.
sudo ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so
sudo ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so
Download php 5.5 from official site, extract it then.
wget https://www.php.net/distributions/php-5.5.9.tar.gz
tar -xvzf php-5.5.9.tar.gz
cd php-5.5.9
Using cURL.
curl -OJ https://www.php.net/distributions/php-5.5.9.tar.gz
tar -xvzf php-5.5.9.tar.gz
cd php-5.5.9
Configure.
./configure \
--prefix=/opt/php \
--with-config-file-path=/opt/php \
--with-apxs2=/usr/bin/apxs \
--enable-mbstring \
--with-curl \
--with-openssl \
--enable-soap \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-mysql \
--enable-zip \
--with-mcrypt \
--enable-fpm \
--enable-calendar \
--enable-sysvsem \
--enable-sysvshm \
--enable-exif \
--enable-bcmath \
--enable-opcache \
--with-mhash \
--with-gettext \
--with-bz2 \
--enable-ftp \
--with-kerberos \
--with-xmlrpc \
--with-freetype-dir \
--with-ldap \
--enable-intl \
--with-xsl \
--with-zlib \
--with-mysqli \
--with-pdo-mysql \
--enable-sysvmsg \
--enable-pcntl \
--enable-dba \
--enable-shmop
Perform build.
make
sudo checkinstall
Create a link for php.
sudo ln -s /opt/php/bin/* /usr/local/bin/
Paste php configuration file, link them after.
sudo cp php.ini-production /opt/php/php.ini
sudo ln -s /opt/php/php.ini /etc
Execute php
and see the result.
If you happens to own multi core server (which I do), you can utilize that to make command.
make -j4
Where 4 is your core number, parameter is-j{core_number}
.
Upon restarting apache, I get such error.
Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP
Luckily, the solution is quite easy.
sudo a2dismod mpm_event && sudo a2enmod mpm_prefork
sudo /etc/init.d/apache2 restart