Skip to content

Instantly share code, notes, and snippets.

@L1so
Created February 27, 2022 10:35
Show Gist options
  • Save L1so/399329db89aa7bb102d9e041d10dc44a to your computer and use it in GitHub Desktop.
Save L1so/399329db89aa7bb102d9e041d10dc44a to your computer and use it in GitHub Desktop.
Install php 5.5.9 from source on Ubuntu 16.04

Installing php 5.5.9 on Ubuntu 16.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 \
	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.


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