I'd like to install a very old PHP version on debian 8. Namely PHP 5.1.0. I will not use this in production, it is just for testing purposes. However, if I try to compile it I run into problems with the dom module. After a little bit of research I found out that libxml2 versions >= 2.9 cause problems with those older PHP versions. Now I'd like to know if it is possible to compile libxml2 2.8, save it somewhere and use it to compile php 5.1. If it's possible, can you tell me how?
How can I compile an old PHP version and dependencies on debian 8? (PHP 5.1.0 in this case)
debian;compiling;php;libraries;dependencies
You definitely can do this, but it can get annoying.I'd put libxml 2.8 in a separate prefix (./configure --prefix=/path/to/prefix/) alongside PHP 5.1.0 (e.g. /opt/php510/ or /usr/local/php510/), since you don't want to risk overriding the newer library with an older one. You'd definitely be best off if you build libxml 2.8 statically, so it gets baked into PHP and you can avoid 'shared library hell' when starting the program. Typically this would be done by adding --disable-shared --enable-static to the configure flags.Then on the PHP end, you'd have to configure it to use the same prefix, and also add the libxml 2.8 library paths to your GCC invocation. If it uses autoconf to build (./configure scripts are usually autoconf generated), you'd want to run something like CFLAGS=-I/opt/php510/include LDFLAGS=-L/opt/php510/lib ./configure --prefix=/opt/php510.CFLAGS is a variable that contains arguments passed to gcc when creating .o object files. -I/path tells GCC to look for headers (includes, or .h files) in /path in before looking in the default list (typically /usr/include and /include IIRC).LDFLAGS is a variable that contains arguments passed to the linker (typically ld, although it is also possible to use gcc as a linker to combine .o files into an executable program. autoconf respects this variable in both usages). -L/path tells the linker to look for library files (static .a files or shared object .so files) in /path.If you link libxml 2.8 as a shared library you will get an error like libxml.so.2.8 not found since /etc/ld.so.conf hasn't been told to look for shared libraries in /opt/php510/lib. That's why I recommend using a statically linked version.If you have any problems doing this or if something is using a different build system, let me know.You also might be able to just fix PHP to use the libxml >= 2.9 versions of whatever functions are causing it to mess up, although finding old deprecation notices for already-removed functions is sometimes difficult.