Sometimes you have to test a bad idea, or you just don’t want/can’t to let that 10+ years old ugly and unmaintained project die no matter what, and for that you might have to use a EOL unsupported PHP version
First install the necessary build tools, some of which you may not need:
apt-get install -y autoconf2.13 libbz2-dev libcurl4-openssl-dev libltdl-dev libmcrypt-dev libevent-dev libmhash-dev libmysqlclient-dev libpcre3-dev libpng12-dev libxml2-dev make patch xmlstarlet make patch libssl-dev libssl1.0.0
Then, download the offending php version from the http://museum.php.net, unzip it, and try to compile it with the snippet bellow:
wget http://museum.php.net/php5/php-5.2.17.tar.bz2
bunzip2 php-5.2.17.tar.bz2
tar xf php-5.2.17.tar
cd php-5.2.17/
./configure --enable-fastcgi --enable-fpm --enable-mbstring --enable-sockets --with-config-file-path=/etc/php --with-curl --with-fpm-conf=/etc/php/php-fpm.conf --with-fpm-log=/var/log/php/php_errors.log --with-fpm-pid=/var/run/php/php-fpm.pid --with-gd --with-gettext --with-libdir --with-mcrypt --with-mhash --with-mysql --with-mysql-sock --with-mysqli --with-openssl --with-pcre-regex --with-png-dir --with-zlib --without-sqlite --with-libdir=/lib/x86_64-linux-gnu/ --disable-simplexml
But as you run ‘./configure’ you’ll notice the following warning:
...
Notice: Following unknown configure options were used:
--enable-fpm
--with-fpm-conf=/etc/php/php-fpm.conf
--with-fpm-log=/var/log/php/php_errors.log
--with-fpm-pid=/var/run/php/php-fpm.pid
Check './configure --help' for available options
What this means is that the php-fpm source is not included in the php52 base version, that’s easily fixed with the php-fpm patch:
wget https://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
gunzip php-5.2.17-fpm-0.5.14.diff.gz
cd php-5.2.17/
make clean
patch -p1 -i ../php-5.2.17-fpm-0.5.14.diff
./configure --enable-fastcgi --enable-fpm --enable-mbstring --enable-sockets --with-config-file-path=/etc/php --with-curl --with-fpm-conf=/etc/php/php-fpm.conf --with-fpm-log=/var/log/php/php_errors.log --with-fpm-pid=/var/run/php/php-fpm.pid --with-gd --with-gettext --with-libdir --with-mcrypt --with-mhash --with-mysql --with-mysql-sock --with-mysqli --with-openssl --with-pcre-regex --with-png-dir --with-zlib --without-sqlite --with-libdir=/lib/x86_64-linux-gnu/ --disable-simplexml
make
But alas as with anything worth doing in life, it’s not simple nor easy, and you’ll soon get the following error during compilation:
...
/usr/src/php/php-5.2.17/ext/dom/node.c: In function ‘dom_canonicalization’:
/usr/src/php/php-5.2.17/ext/dom/node.c:1953:21: error: dereferencing pointer to incomplete type
ret = buf->buffer->use;
^
In file included from /usr/src/php/php-5.2.17/main/php.h:38:0,
from /usr/src/php/php-5.2.17/ext/dom/node.c:26:
/usr/src/php/php-5.2.17/ext/dom/node.c:1955:40: error: dereferencing pointer to incomplete type
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
^
/usr/src/php/php-5.2.17/Zend/zend_API.h:472:14: note: in definition of macro ‘ZVAL_STRINGL’
char *__s=(s); int __l=l; \
^
/usr/src/php/php-5.2.17/ext/dom/node.c:1955:5: note: in expansion of macro ‘RETVAL_STRINGL’
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
^
Makefile:576: recipe for target 'ext/dom/node.lo' failed
make: *** [ext/dom/node.lo] Error 1
This means this version is too old to compile in any semi-modern Linux distribution, and in the case of Debian 8 the php-fpm version 5.2.17 is incompatible with the libxml2 version installed in the system, but I hear you say “bullshit this won’t stop me from executing this really bad idea!” and that’s why I’m here to help, so before thinking about downgrading your libxml2 installation, a better ( at least less bad ) alternative is to download a patch from https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt and apply it, I’ve appended a copy of the patch bellow in case they ever remove this monstrosity from their archives.
php-5.2.17-xml-patch.diff
--- ext/dom/node.c 2012-08-06 17:49:48.826716692 +0800
+++ ext/dom/node.c 2012-08-06 17:52:47.633484660 +0800
@@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNA
RETVAL_FALSE;
} else {
if (mode == 0) {
+#ifdef LIBXML2_NEW_BUFFER
+ ret = xmlOutputBufferGetSize(buf);
+#else
ret = buf->buffer->use;
+#endif
if (ret > 0) {
+#ifdef LIBXML2_NEW_BUFFER
+ RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1);
+#else
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
+#endif
} else {
RETVAL_EMPTY_STRING();
}
--- ext/dom/documenttype.c 2012-08-06 18:02:16.019640870 +0800
+++ ext/dom/documenttype.c 2012-08-06 18:06:16.612228905 +0800
@@ -205,7 +205,13 @@ int dom_documenttype_internal_subset_rea
if (buff != NULL) {
xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL);
xmlOutputBufferFlush(buff);
+
+#ifdef LIBXML2_NEW_BUFFER
+ ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff),
+ xmlOutputBufferGetSize(buff), 1);
+#else
ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1);
+#endif
(void)xmlOutputBufferClose(buff);
return SUCCESS;
}
--- ext/simplexml/simplexml.c 2012-08-06 18:10:44.621017026 +0800
+++ ext/simplexml/simplexml.c 2012-08-06 18:12:48.016270419 +0800
@@ -1417,7 +1417,12 @@ SXE_METHOD(asXML)
xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding);
xmlOutputBufferFlush(outbuf);
+#ifdef LIBXML2_NEW_BUFFER
+ RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf),
+ xmlOutputBufferGetSize(outbuf), 1);
+#else
RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1);
+#endif
xmlOutputBufferClose(outbuf);
}
} else {
To Compile with this patch run the snippet bellow:
wget https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt -o php-5.2.17-xml.diff
cd php-5.2.17/
patch -p0 -i ../php-5.2.17-xml.diff
make clean
./configure --enable-fastcgi --enable-fpm --enable-mbstring --enable-sockets --with-config-file-path=/etc/php --with-curl --with-fpm-conf=/etc/php/php-fpm.conf --with-fpm-log=/var/log/php/php_errors.log --with-fpm-pid=/var/run/php/php-fpm.pid --with-gd --with-gettext --with-libdir --with-mcrypt --with-mhash --with-mysql --with-mysql-sock --with-mysqli --with-openssl --with-pcre-regex --with-png-dir --with-zlib --without-sqlite --with-libdir=/lib/x86_64-linux-gnu/ --disable-simplexml
make && make install
If everything went acording to plan and now that you have a fully functioning ancient php version installed on your system, you can test it with:
php -v
It should output something like this:
PHP 5.2.17 (cli) (built: Mar 9 2019 00:00:00)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
Just look at the copyright notice of this bad boy, only 8+ worth of not fixing bugs anymore.
Now there are only two things left to do to configure the php-fpm service:
First create a systemd unit, it’s easy just run the following as root:
echo '[Unit]
Description=The PHP FastCGI Process Manager
After=network.target
[Service]
Type=notify
PIDFile=/var/run/php5-fpm.pid
ExecStartPre=/usr/local/lib/php/php5-fpm-checkconf
ExecStart=/usr/local/sbin/php-fpm start
ExecReload=/bin/kill -USR2 $MAINPID' > /lib/systemd/system/php5-fpm.service
Second reload the unit files and enable the service:
systemctl daemon-reload
systemctl enable php5-fpm.service
systemctl start php5-fpm.service
In this section you’ll find a full shell script to do everything described above in one step.
wget http://museum.php.net/php5/php-5.2.17.tar.bz2
wget https://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
wget https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt -o php-5.2.17-xml.diff
bunzip2 php-5.2.17.tar.bz2
tar xf php-5.2.17.tar
gunzip php-5.2.17-fpm-0.5.14.diff.gz
cd php-5.2.17/
patch -p1 -i ../php-5.2.17-fpm-0.5.14.diff
patch -p0 -i ../php-5.2.17-xml.diff
./configure --enable-fastcgi --enable-fpm --enable-mbstring --enable-sockets --with-config-file-path=/etc/php --with-curl --with-fpm-conf=/etc/php/php-fpm.conf --with-fpm-log=/var/log/php/php_errors.log --with-fpm-pid=/var/run/php/php-fpm.pid --with-gd --with-gettext --with-libdir --with-mcrypt --with-mhash --with-mysql --with-mysql-sock --with-mysqli --with-openssl --with-pcre-regex --with-png-dir --with-zlib --without-sqlite --with-libdir=/lib/x86_64-linux-gnu/ --disable-simplexml
make && make install
echo '[Unit]
Description=The PHP FastCGI Process Manager
After=network.target
[Service]
Type=notify
PIDFile=/var/run/php5-fpm.pid
ExecStartPre=/usr/local/lib/php/php5-fpm-checkconf
ExecStart=/usr/local/sbin/php-fpm start
ExecReload=/bin/kill -USR2 $MAINPID' > /lib/systemd/system/php5-fpm.service
systemctl daemon-reload
systemctl enable php5-fpm.service
systemctl start php5-fpm.service
Sources
http://museum.php.net/php5/
https://php-fpm.org/downloads/
https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
https://hub.docker.com/r/helder/php-5.2/dockerfile/
https://xuniltech.wordpress.com/2013/09/12/install-php-5-2-on-wheezy-debian-7/
http://snapshot.debian.org/package/php5/5.2.12.dfsg.1-2/
https://hub.docker.com/search/?q=php%205.2&type=image
https://www.centos.org/forums/viewtopic.php?t=53046