Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

#!/bin/bash

#######################################################################
# This script upgrades php into newer version with simply passing     #
# version as an argument i.e. sh upgrade_php.sh PHP-5.3.17 (if        #
# i want to upgrade to given version.)                                #
#                                                                     #
# This script usage repo of uk.php.net which might not work if there  #
# is change with layout of repository, you might simply want to change#
# URL on REPO on line 35                                              #
#                                                                     #
# NOTE: So far this script only identifies HTTPD/LIGHTTPD, which      #
# has to be changed according to your need on line 45 (i.e. grep )    #
#######################################################################

function chkInput
                {
                if [ -z "$1" ];then
                displayUsage
                exit 0;
                fi
                }

function displayUsage
                {
                echo "Please enter php version you want to upgrade for"
                echo "If you want to upgrade php version 5.3.17 please write PHP-5.3.17"
                echo "Usage: sh upgrade_php.sh PHP-5.x.x"
                }



chkInput $1

REPO=`echo http://uk.php.net/get/$1.tar.gz/from/this/mirror | sed -e's/PHP/php/g'`


CUR_VERSION=`php --version | head -1 | cut -d' ' -f1,2 | sed -e 's/PHP /php-/g'`
CONFIGURE=`php -i | grep -i configure | awk '{for (i=1; i<=NF-3; i++) $i = $(i+3); NF-=3; print}'`
TARFILE=`echo $REPO | cut -d"/" -f5`
VERSION=`echo $REPO | cut -d"/" -f5 | sed -e's/.......$//g'`
SRC="/usr/local/src"
LOCALREPO="/usr/local/src/$VERSION/"

WEBSERVER=`netstat -tupan | grep -i 80 | grep -i "httpd" | awk '{ print $7}' | cut -d'/' -f2 | sort | uniq`




         if [ "$CUR_VERSION" = "$VERSION" ]; then
         echo 'Old Version: '$CUR_VERSION' Is same as Target Version: '$VERSION''


         else
                echo " Preparing PHP Upgrade from $CUR_VERSION to $VERSION "

                        read -t 5 -p "Press 'Q' to abort within 5 seconds..:" confirm

                                if [ "$confirm" != 'Q' ];then

                                                `cd $SRC && wget $REPO && tar -zxvf $TARFILE && cd $VERSION && $CONFIGURE && make && make install && service $WEBSERVER restart`

                                else
                                                echo "User Abort,exiting..."
                                fi
        fi

###### Standard PHP Config

./configure  --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5 --with-apxs2 --with-openssl --with-kerberos --with-zlib --with-bz2 --enable-calendar --with-curl --enable-dba --with-db4 --with-gdbm --enable-ftp --with-gd --with-jpeg-dir=/usr/lib64 --with-png-dir=/usr/lib64 --enable-gd-native-ttf --with-gettext --with-mhash --with-imap --with-imap-ssl --with-ldap --with-ldap-sasl --enable-mbstring --with-mcrypt --with-mysql --enable-soap --enable-sockets --enable-sqlite-utf8 --enable-zip --with-libdir=lib64 --with-iconv --with-xmlrpc --with-mime-magic --enable-pdo --with-gd-ttf --with-freetype-dir=/usr/include/freetype2/ --enable-intl --enable-bcmath