Please make sure the latest MySQL version installed is 5.6 or MariaDB is 10.1, else the PHP 5.2 cannot be installed.
The PHP 5.2 only can be installed and running as suphp. Firstly we need to install the suphp. Use the DirectAdmin custombuild, it will help to install everything required.
# cd /usr/local/directadmin/custombuild # ./build set php1_release 5.6 # ./build set php1_mode suphp # ./build php n
Once the suphp installed, we need to revert back the ph handler to our standard setup. For our Linux Hosting, the first PHP version is 5.6 (mod_php) and second PHP version is 5.4 (fastcgi).
# ./build set php1_release 5.6 # ./build set php1_mode mod_php # ./build set php2_release 5.3 # ./build set php2_mode fastcgi # ./build php n
Now, we can start to install PHP 5.2
# cd /usr/local/directadmin/custombuild # wget http://files.directadmin.com/services/custombuild/php-5.2.17.tar.gz # wget -O php-5.2.17-apache24.patch --user=support --password=Jz8jx001 https://ns82.small-dns.com/setup/php-5.2.17-apache24.patch # wget -O php-5.2.17-mail-header.patch --user=support --password=Jz8jx001 https://ns82.small-dns.com/setup/php-5.2.17-mail-header.patch # wget -O php-5.2.17-node.patch --user=support --password=Jz8jx001 https://ns82.small-dns.com/setup/php-5.2.17-node.patch # cd php-5.2.17/main # patch -p0 < ../../php-5.2.17-apache24.patch ...... can't find file to patch at input line 3 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |*** php-5.2.17/sapi/apache2handler/php_functions.c.orig 2012-01-18 12:55:15.000000000 +0200 |--- php-5.2.17/sapi/apache2handler/php_functions.c 2012-01-18 12:55:12.000000000 +0200 -------------------------- File to patch: ../sapi/apache2handler/php_functions.c ...... # patch -p0 < ../../php-5.2.17-mail-header.patch ...... can't find file to patch at input line 3 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |--- php-5.2.17/ext/standard/mail.c.original 2009-02-25 23:46:16.000000000 +0800 |+++ php-5.2.17/ext/standard/mail.c 2009-02-25 23:46:56.000000000 +0800 -------------------------- File to patch: ../ext/standard/mail.c ...... # patch -p0 < ../../php-5.2.17-node.patch ...... can't find file to patch at input line 3 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |--- ext/dom/node.c 2012-08-06 17:49:48.826716692 +0800 |+++ ext/dom/node.c 2012-08-06 17:52:47.633484660 +0800 -------------------------- File to patch: ../ext/dom/node.c patching file ../ext/dom/node.c Hunk #1 succeeded at 1950 (offset 55 lines). can't find file to patch at input line 23 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |--- ext/dom/documenttype.c 2012-08-06 18:02:16.019640870 +0800 |+++ ext/dom/documenttype.c 2012-08-06 18:06:16.612228905 +0800 -------------------------- File to patch: ../ext/dom/documenttype.c patching file ../ext/dom/documenttype.c Hunk #1 succeeded at 215 (offset 10 lines). can't find file to patch at input line 39 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |--- ext/simplexml/simplexml.c 2012-08-06 18:10:44.621017026 +0800 |+++ ext/simplexml/simplexml.c 2012-08-06 18:12:48.016270419 +0800 -------------------------- File to patch: ../ext/simplexml/simplexml.c patching file ../ext/simplexml/simplexml.c Hunk #1 succeeded at 1343 (offset -74 lines). ......
cd /usr/local/directadmin/custombuild/php-5.2.17 vi install.sh
#!/bin/sh
./configure \
--prefix=/usr/local/php52 \
--program-suffix=52 \
--with-config-file-scan-dir=/usr/local/php52/lib/php.conf.d \
--with-curl=/usr/local/lib \
--with-gd \
--enable-gd-native-ttf \
--with-gettext \
--with-jpeg-dir=/usr/local/lib \
--with-freetype-dir=/usr/local/lib \
--with-libxml-dir=/usr/local/lib \
--with-kerberos \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-mysql=mysqlnd \
--with-mysql-sock=/var/lib/mysql/mysql.sock \
--with-mysqli=/usr/bin/mysql_config \
--with-pcre-regex=/usr/local \
--with-pdo-mysql=/usr/bin/mysql_config \
--with-pear \
--with-png-dir=/usr/local/lib \
--with-xsl \
--with-zlib \
--with-zlib-dir=/usr/local/lib \
--enable-zip \
--with-iconv=/usr/local \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-sockets \
--enable-soap \
--enable-mbstring
# chmod 700 install.sh # ./install.sh # make # make install
Once the installation complete, you can verify with
# /usr/local/php52/bin/php52 -v PHP 5.2.17 (cli) (built: Jun 12 2018 21:55:58) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies # /usr/local/php52/bin/php-cgi52 -v PHP 5.2.17 (cgi) (built: Jun 12 2018 21:55:46) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
# wget -O /usr/local/suphp/etc/suphp.conf --user=support --password=Jz8jx001 https://ns82.small-dns.com/setup/suphp.conf # wget -O /usr/local/php52/lib/php.ini --user=support --password=Jz8jx001 https://ns82.small-dns.com/setup/php-5.2.17-php.ini # vi /etc/httpd/conf/extra/httpd-includes.conf
[cc]
LoadModule suphp_module /usr/lib/apache/mod_suphp.so
AddHandler x-httpd-php52 .php52
suPHP_Engine on
suPHP_ConfigPath /usr/local/php52/lib/
suPHP_AddHandler x-httpd-php52
[/cc]
In custom httpd configuration, below is the config need to be added. [USER] referring to the hosting account username.
[cc]
suPHP_UserGroup [USER] [USER]
AddHandler x-httpd-php52 .php
[/cc]