[advanced level] How to install more than 2 PHP versions with CustomBuild 2.x

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
14,255
Location
GMT +7.00
Hello,

Just some hours earlier I've installed PHP 5.2, PHP 5.3, PHP 5.4 as (!!!) suPHP (!!!) on a server with MySQL 5.5. The old PHP 5.2 was installed manually the others I've installed with CustomBuild 2. I'm not tested whether or not it is possible to install PHP 5.2 with MySQL 5.6 support.

That way you may install so many PHP versions (PHP 5.5, PHP 5.6) as you might want, but only two of them you will be able to choose in Directadmin Web-GUI (should have CustomBuild 2.0 and actual version of the Directadmin CP) without 3rd party`s plugins.

1. I've downloaded PHP 5.2. from http://files.directadmin.com/services/custombuild/php-5.2.17.tar.gz with a patch http://files.directadmin.com/services/custombuild/php-5.2.17-patched-mail-header.patch

Code:
cd /usr/local/directadmin/custombuild
wget http://files.directadmin.com/services/custombuild/php-5.2.17.tar.gz
wget http://files.directadmin.com/services/custombuild/php-5.2.17-mail-header.patch


2. Copied configure/suphp/configure.php from CustomBuild 1.2 to /usr/local/directadmin/custombuild/custom/suphp/configure.php52 (CustomBuild 2.0) and modified it to the following state:

Code:
#!/bin/sh
"./configure" \
"--prefix=/usr/local/php52" \
"--enable-force-cgi-redirect" \
"--enable-fastcgi" \
"--with-config-file-path=/usr/local/php52/lib" \
"--with-curl=/usr/local/lib" \
"--with-gd" \
"--enable-gd-native-ttf" \
"--with-ttf" \
"--with-gd-dir=/usr/local/lib" \
"--with-gettext" \
"--with-jpeg-dir=/usr/local/lib" \
"--with-freetype" \
"--with-freetype-dir=/usr/local/lib" \
"--with-kerberos" \
"--with-mcrypt" \
"--with-mhash" \
"--with-mysql=/usr" \
"--with-mysqli=/usr/bin/mysql_config" \
"--with-pcre-regex=/usr/local" \
"--with-pdo-mysql=/usr" \
"--with-pear=/usr/local/lib/php" \
"--with-png-dir=/usr/local/lib" \
"--with-xml" \
"--with-xmlrpc" \
"--with-xsl" \
"--with-zlib" \
"--with-zlib-dir=/usr/local/lib" \
"--enable-zip" \
"--enable-wddx" \
"--with-bz2=/usr" \
"--with-zip" \
"--with-openssl" \
"--with-openssl-dir=/usr/local/lib" \
"--with-imap=/usr/lib64" \
"--with-imap-ssl" \
"--with-iconv=/usr/local" \
"--enable-bcmath" \
"--enable-calendar" \
"--enable-exif" \
"--enable-ftp" \
"--enable-magic-quotes" \
"--enable-sockets" \
"--enable-track-vars" \
"--enable-mbstring" \
"--enable-mailparse" \
"--disable-posix" \
"--enable-memory-limit" \
"--enable-soap"
3. Extracted php-5.2.17.tar.gz and applied the patch php-5.2.17-patched-mail-header.patch

Code:
cd /usr/local/directadmin/custombuild
tar -zxvf php-5.2.17.tar.gz
patch -p 0 < php-5.2.17-mail-header.patch
4. Executed the configure.php52 in a php-5.2.17 directory, and then installed php-5.2.17


Code:
cd /usr/local/directadmin/custombuild/php-5.2.17
copy /usr/local/directadmin/custombuild/custom/suphp/configure.php52 .
chmod 700 configure.php52
./configure.php52
make && make install
5. Modified /usr/local/suphp/etc/suphp.conf and added line

x-httpd-php52="php:/usr/local/php52/bin/php-cgi"

after

;Handler for php-scripts

Code:
[handlers];Handler for php-scripts
x-httpd-php52="php:/usr/local/php52/bin/php-cgi"
x-httpd-php53="php:/usr/local/php53/bin/php-cgi53"
x-httpd-php54="php:/usr/local/php54/bin/php-cgi54"
# x-httpd-php55="php:/usr/local/php53/bin/php-cgi55"
# x-httpd-php56="php:/usr/local/php54/bin/php-cgi56"

and chattr`ed the file immutable:

Code:
chattr +i /usr/local/suphp/etc/suphp.conf
6. Updated /etc/httpd/conf/extra/httpd-suphp.conf to the following view:

Code:
<IfModule mod_suphp.c>
<FilesMatch "\.(inc|php|php3|php4|php44|php5|php52|php53|php54|php55|php56|php6|phtml|phps)$">
AddHandler x-httpd-php52 .php52
AddHandler x-httpd-php53 .php53 .inc .php .php3 .php4 .php5 .phtml
AddHandler x-httpd-php54 .php54
# AddHandler x-httpd-php55 .php55
# AddHandler x-httpd-php56 .php56
</FilesMatch>
<Location />
suPHP_Engine on
#suPHP_ConfigPath /usr/local/php53/lib/
suPHP_AddHandler x-httpd-php52
suPHP_AddHandler x-httpd-php53
suPHP_AddHandler x-httpd-php54
# suPHP_AddHandler x-httpd-php55
# suPHP_AddHandler x-httpd-php56
</Location>
</IfModule>
and chattr`ed the file immutable:

Code:
chattr +i /etc/httpd/conf/extra/httpd-suphp.conf

7. Modified virtual host templates to have suPHP_ConfigPath pointing to user's home (old way here):

Code:
suPHP_ConfigPath |HOME|/
8. Restart apache

9. That's it. Now to use PHP 5.2 I need to add

Code:
<FilesMatch "\.(inc|php|php3|php4|php44|php5|php52|php53|php54|php55|php56|php6|phtml|phps)$">
AddHandler x-httpd-php52 .php52 .inc .php .php3 .php4 .php5 .phtml
</FilesMatch>
into a .htaccess file.
 
Last edited:

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
14,255
Location
GMT +7.00
To have the guide to work you should have at least one PHP version (as suPHP) installed with either CB 1.x or CB 2.x to have ready structure in Apache. If you install 2 PHP versions with CustomBuild 2.x then one of them can be mod_php+mod_ruid2. But still that's not recommended to use mod_ruid2 and suPHP on one server.
 
Top