Ubuntu 14.04 con Apache & PHP 5.3

By | 29 March 2021

One of the difficulties I encountered during my work is to enable the https/tls 1.2 protocol for old applications developed with PHP 4.4. The most obvious thing would be to update/redo the application with a newer version of PHP, for example 5.6 or better still with a 7.4 or 8.0. However, it is not always possible, either because the customer cannot afford to spend to update it, or because it is an application that interacts with Legacy systems, or because a version of the same is already in progress but for the moment that old must continue to work.

After installing the Ubuntu 14.04 server version (32 or 64 bit version), install the following packages

apt-get install build-essential libxml2-dev apache2 apache2-dev libssl-dev libsslcommon2-dev libbz2-dev libcurl4-gnutls-dev libpng12-dev libgmp-dev libmcrypt-dev libtidy-dev libxslt1-dev libltdl-dev libjpeg-dev libgif-dev libmysqlclient-dev libmysqlclient18 icu-devtools libicu-dev 

Download the latest version of php5.3, decompress and configure.

./configure --with-libdir=lib/i386-linux-gnu --with-apxs2 --with-openssl --with-pcre-regex --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --with-gettext --with-gmp --with-mhash --enable-intl --enable-mbstring --with-mcrypt --with-mysql --with-mysql-sock --with-mysqli --enable-pcntl --with-pdo-mysql --enable-sockets --with-tidy --enable-wddx --with-xmlrpc --with-xsl --enable-zip --with-png-dir --with-jpeg-dir

In caso di versione dell’os a 64 bit modificare il parametro –with-libdir=lib/x86_64-linux-gnu .

Aggiungere alla riga che inizia per “EXTRA_LIBS” il valore “-lstdc++” (si può mettere come primo parametro). Senza questo valore da questo errore durante la compilazione:

error adding symbols: DSO missing from command line

Questa è la riga dopo la modifica

EXTRA_LIBS = -lstdc++ -lcrypt -lz -lexslt -ltidy -lresolv -lcrypt -lrt -lmysqlclient …

Infine procedere con la compilazione e l’installazione.

make
make test
make install

Copiare il file php.ini di produzione nella directory corretta e fare le modifiche necessarie.

cp /opt/php-source/php-5.3.29/php.ini-production /usr/local/lib/php.ini

Durante l’installazione non viene creato il file di configurazione che aggiunge il tipo .php ad Apache. Creare quindi il file /etc/apache2/mods-available/php5.conf con il seguente contenuto

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .php

Disattivare e riattivare il modulo php e riavviare apache.

a2dismod php5
a2enmod php5
service apache2 restart

Enjoy!