http://forums.cpanel.net/showthread.php?t=45908
#!/bin/sh
cd /usr/src
cp -rpf /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.php4
cp -rpf /usr/local/apache/libexec /usr/local/apache/libexec.php4
wget http://www.mycutelife.net/sanju/php4and5/php-5.0.5-mail-header.patch
wget http://www.mycutelife.net/sanju/php4and5/php-5.0.5.tar.gz
tar -zxvf php-5.0.5.tar.gz
cd php-5.0.5/
patch -p1 < /usr/src/php-5.0.5-mail-header.patch
./configure --prefix=/usr/local/php5 --with-xml --with-mm --enable-bcmath --enable-calendar --with-curl --with-dom --with-dom-xslt --with-dom-exslt --enable-exif --with-swf=/usr/local/flash --enable-ftp --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr --with-xpm-dir=/usr/X11R6 --with-gettext --with-imap=/usr/local/imap-2004g --enable-mbstring --enable-mbstr-enc-trans --enable-mbregex --with-mcrypt --with-mhash --enable-magic-quotes --with-mm --with-mysqli --with-mysql=/usr --with-snmp --enable-ucd-snmp-hack --with-openssl --enable-discard-path --with-pear --with-pspell --enable-safe-mode --enable-sockets --enable-track-vars --with-ttf --with-freetype-dir=/usr --enable-gd-native-ttf --enable-versioning --enable-wddx --with-xmlrpc --with-zip --with-zlib --prefix=/usr/local/php5 --exec-prefix=/usr/local/php5 --program-suffix=5 --enable-force-cgi-redirect
make
make install
cp -f php.ini-recommended /usr/local/php5/lib/php.ini
cp /usr/local/php5/bin/php5 /usr/local/cpanel/cgi-sys/php5
chown root:wheel /usr/local/cpanel/cgi-sys/php5
PHP5CONF=`$GREP php5.conf /usr/local/apache/conf/httpd.conf`
if [ "$PHP5CONF" = "" ]; then
echo "Action application/x-httpd-php5 \"/cgi-sys/php5\"" > /usr/local/apache/conf/php5.conf
echo "AddType application/x-httpd-php5 .php5" >> /usr/local/apache/conf/php5.conf
echo "Include /usr/local/apache/conf/php5.conf" >> /usr/local/apache/conf/httpd.conf
fi
CONFIGTEST=`/etc/init.d/httpd configtest | $GREP -m1 Syntax | $AWK '{print $2 }'`
if [ "$CONFIGTEST" = "OK" ]; then
echo "Restarting Apache now..."
/etc/init.d/httpd restart
echo "Done. Enjoy PHP5!"
else
echo "There may have been a problem with this installation."
echo "Please check the httpd.conf for syntax with '/etc/init.d/httpd configtest'"
fi