Compiling PHP 5.1.6 on a recent Linux
An unforseen need required me to put a six years old PHP 5.1 application back online for a few weeks in my customer Intranet. Between rewriting or adapt a significant portion of the code to make it work on 5.3+ or getting back a system with a running 5.1 PHP with its Oracle dependencies, business and team constraints usually give little choice:
- Nearly no budget was available,
- Most of the coding team were already booked on others projects,
- Most of them were reluctant to work on old and crapy code,
- The website is internal only,
- There’s significant incompatibilities between 5.1 and 5.3 (5.1 to 5.2, and 5.2 to 5.3).
- The UI is not complex and has nearly no Javascript.
Compilation for a temporary site seemed to be the solution with the lowest duration and risks, however I had to adjust PHP 5.1 a bit to make it work with our recent Centos systems. Here the parts I had to modify :
The Curl extension
CURLOPT_FTPASCII was a deprecated constant, alias of CURLOPT_TRANSFERTEXT and has now been removed from recent Curl include. The constant must be removed from PHP as sown in the following patch.
The Openssl extension
openssl/lhash.h implements a dynamic hash tables systems, but nowaday versions gives the ability to specity types of tables: the macro changed and the PHP extension needs to be adjusted accordingly.
The OCI extension
If you want to add support of recent Oracle client, I strongly suggest you to ignore the 5.1 ext/oci extensions. It’s way easier to grab the current PECL one: PHP needs to be compiled without OCI support, and once it’s properly installed we use the pecl command to install a working OCI.