Skip to content

Instantly share code, notes, and snippets.

@L1so
Last active September 6, 2022 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L1so/f0fc981aa589433d5a6433e5ac80a77f to your computer and use it in GitHub Desktop.
Save L1so/f0fc981aa589433d5a6433e5ac80a77f to your computer and use it in GitHub Desktop.

Installing php 5.5.9 on Ubuntu 18.04 - 20.04

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 \
    libcurl4-gnutls-dev \
    libmcrypt-dev \
    libxml2-dev \
    libjpeg-dev \
    libpng-dev \
    libxpm-dev \
    libmysqlclient-dev \
    libpq-dev \
    libbz2-dev \
    libicu-dev \
    libfreetype6-dev \
    libldap2-dev \
    libxslt-dev \
    libbz2-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, follow this first → Build custom OpenSSL

./configure \
--prefix=/opt/php \
--with-config-file-path=/opt/php \
--with-apxs2=/usr/bin/apxs \
--enable-mbstring \
--with-curl=/usr/local/curl-with-openssl-1.0 \
--with-openssl=/usr/local/openssl-1.0 \
--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

Hold php to prevent them from auto updating.

sudo apt-mark hold php

Execute php and see the result.


Optional steps #1

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}.

Optional steps #2

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment