Compling PHP4 with PHP5 on Plesk

Download PHP 4 source http://www.php.net/downloads.php :

[root@server]# cd /usr/local/src
[root@server]# wget http://museum.php.net/php4/php-4.4.7.tar.gz

UNTAR
[root@server]# tar -zxf php-4.4.5.tar.gz

CONFIGURE & COMPILE PHP4

[root@server]# cd php-4.4.7

[root@server]# ./configure '--prefix=/usr/local/php4' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include'
'--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--with-libdir=lib' '--with-config-file-path=/usr/local/php4/lib' '--with-pic' '--disable-rpath' '--with-exec-dir=/usr/bin' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-iconv' '--with-jpeg-dir=/usr' '--with-png' '--with-zlib' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-pear=/usr/share/pear' '--enable-calendar' '--with-libxml-dir=/usr' '--with-xml' '--enable-force-cgi-redirect' '--enable-pcntl' '--enable-mbstring' '--enable-mbregex' '--with-ncurses' '--with-gd' '--enable-bcmath' '--with-xmlrpc' '--with-mysql' '--with-mysqli' '--enable-dom' '--with-xsl' '--enable-fastcgi' '--program-suffix=4' '--with-expat-dir=/usr'

Note :: You may get too many errors while configuring PHP which can be easily resolved by installing required devel through YUM
(For exa:: yum install libmhash-devel), also you can always choose to remove an option above from the compile command if you can't or don't want to install a dependency..


Once the complie command succeeds, run:

make

then

make install

then Copy php source files.

[root@server]# cp -rf ./sapi/cgi/php /usr/local/php4/bin/
[root@server]# mkdir -pv /etc/httpd/cgi-sys/
[root@server]# cp -rf ./sapi/cgi/php /etc/httpd/cgi-sys/
[root@server]# cp -rf php.ini-recommended /usr/local/php4/lib/php.ini

Make a php4.conf file:

The previous PHP5 installation created a the file /etc/httpd/conf.d/php.conf- duplicate this file and rename it php4.conf, then edit the "DirectoryIndex" "Action" and "AddHandler" lines with the following information:

DirectoryIndex index.php4 index.php3
Action php4-script /cgi-bin/php
AddHandler php4-script .php3 .php4


and comment out the "LoadModule php5..." line

Instead of creating "php4.conf" you can add following lines at the bottom of the file /etc/httpd/conf/httpd.conf

ScriptAlias /cgi-sys/ /etc/httpd/cgi-sys/
Action application/x-httpd-php4 "/cgi-sys/php"
AddHandler application/x-httpd-php4 .php4


and then restart Apache:
[root@server]# /etc/init.d/httpd restart

Create link to PHP4 in Client's cgi-bin Directory
# Due to Security Issues the PHP4 CGI is installed at /usr/local/etc/php4/cgi/php.ini. In the Interworx virtual host setup using suexec, each user has their own cgi-bin. Do the following to link the PHP4 CGI into your hosting client's cgi-bin directory.

[root@server]# cd /chroot/home/client/public_html/cgi-bin
[root@server]# ln /usr/local/php4/bin/php php
[root@server]# chown client php
[root@server]# chgrp client php
[root@server]# chmod 755 php

Test your PHP installation
try creating a php.info doc for both versions of PHP:

/chroot/home/client/public_html/info.php4
/chroot/home/client/public_html/info.php
using the same code:

phpinfo();
?>

The phpinfo() function reports the version number, as well as the features that are compiled into PHP. You'll see that info.php4 uses php4 and info.php5 uses php5.



Most of these steps were gleaned from:

http://www.webhostingtalk.nl/directa...hp5-suphp.html
and
http://www.gsp.com/support/virtual/php/cgi.html
and
http://www.interworx.com/forums/showthread.php?t=1897

Thank You.

    1 comments:

  1. this won't work if you have suexec installed and running..