fsphosting
New Member
Hi
How do i upgrade from php4 to php5 ? i have a linux server with cpanel/whm.
How do i upgrade from php4 to php5 ? i have a linux server with cpanel/whm.
#!/bin/sh
# Abort on any errors
set -e
# Export your username before you execute this script. format
export USER="ghost"
# Update version information here.
export PHP5="php-5.1.4"
LIBICONV="libiconv-1.10"
LIBMCRYPT="libmcrypt-2.5.7"
LIBXML2="libxml2-2.6.24"
LIBXSLT="libxslt-1.1.16"
MHASH="mhash-0.9.6"
ZLIB="zlib-1.2.3"
CURL="curl-7.15.3"
LIBIDN="libidn-0.6.3"
CCLIENT="c-client"
CCLIENT_DIR="imap-2004g"
# ---- end of user-editable bits. Hopefully! ----
# Where to compile source code, will be deleted afterwards
SRCDIR="/home/${USER}/source"
# And where should it be installed?
INSTALLDIR="/home/${USER}/php5"
# Set DISTDIR to somewhere persistent, if you plan to muck around with this
# script and run it several times!
DISTDIR="/home/${USER}/dist"
#PHP Features
PHPFEATURES="--prefix=${INSTALLDIR} --with-config-file-path=${INSTALLDIR}/etc --enable-force-cgi-redirect --with-xml --with-mm --without-iconv --enable-bcmath --enable-calendar --with-curl --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr/X11R6 --with-gettext --enable-mbstring --enable-mbstr-enc-trans --enable-mbregex --with-mcrypt=${INSTALLDIR} --with-mhash --enable-magic-quotes --with-mm --with-mysqli --with-mysql=/usr --with-openssl --enable-discard-path --without-pear --enable-sockets --enable-track-vars --with-ttf --with-freetype-dir=/usr --enable-gd-native-ttf --enable-wddx --with-xmlrpc --with-zip --with-zlib "
# Push the install dir's bin directory into the path
export PATH=${INSTALLDIR}/bin:$PATH
#setup directories
echo 'Setting up directories.....'
mkdir -p ${SRCDIR}
mkdir -p ${INSTALLDIR}
mkdir -p ${DISTDIR}
cd ${DISTDIR}
# Get all the required packages
echo 'Downloading PHP5......'
wget -qc http://us3.php.net/distributions/${PHP5}.tar.gz
echo 'Downloading iconv......'
wget -qc http://ftp.gnu.org/pub/gnu/libiconv/${LIBICONV}.tar.gz
echo 'Downloading mcrypt......'
wget -qc http://easynews.dl.sourceforge.net/sourceforge/mcrypt/${LIBMCRYPT}.tar.gz
echo 'Downloading xml......'
wget -qc http://ftp.acc.umu.se/pub/GNOME/sources/libxml2/2.6/${LIBXML2}.tar.gz
echo 'Downlading xslt......'
wget -qc http://ftp.acc.umu.se/pub/GNOME/sources/libxslt/1.1/${LIBXSLT}.tar.gz
echo 'Downlading mhash......'
wget -qc http://easynews.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz
echo 'Downloading zlib......'
wget -qc http://www.zlib.net/${ZLIB}.tar.gz
echo 'Downloading curl......'
wget -qc http://curl.haxx.se/download/${CURL}.tar.gz
echo 'Downloading idn......'
wget -qc ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
echo 'Downloading cclient......'
wget -qc ftp://ftp.cac.washington.edu/imap/${CCLIENT}.tar.Z
echo 'Change dir to unpack'
cd ${SRCDIR}
# Unpack all the tarballs
echo 'Unpacking php5......'
tar xzf ${DISTDIR}/${PHP5}.tar.gz
echo 'Unpacking iconv......'
tar xzf ${DISTDIR}/${LIBICONV}.tar.gz
echo 'Unpacking mcrypt......'
tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz
echo 'Unpacking xml2......'
tar xzf ${DISTDIR}/${LIBXML2}.tar.gz
echo 'Unpacking xslt......'
tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz
echo 'Unpacking mhash......'
tar xzf ${DISTDIR}/${MHASH}.tar.gz
echo 'Unpacking zlib......'
tar xzf ${DISTDIR}/${ZLIB}.tar.gz
echo 'Unpacking curl......'
tar xzf ${DISTDIR}/${CURL}.tar.gz
echo 'Unpacking idn......'
tar xzf ${DISTDIR}/${LIBIDN}.tar.gz
echo 'Unpacking c-clinet......'
uncompress -cd ${DISTDIR}/${CCLIENT}.tar.Z |tar x
echo 'All unpacked......'
echo 'Lets start building......'
# The beginning of the big build
cd ${SRCDIR}/${LIBICONV}
./configure --enable-extra-encodings --prefix=${INSTALLDIR}
# make clean
make
make install
cd ${SRCDIR}/${LIBXML2}
./configure --with-iconv=${INSTALLDIR} --prefix=${INSTALLDIR}
# make clean
make
make install
cd ${SRCDIR}/${LIBXSLT}
./configure --prefix=${INSTALLDIR} \
--with-libxml-prefix=${INSTALLDIR} \
--with-libxml-include-prefix=${INSTALLDIR}/include/ \
--with-libxml-libs-prefix=${INSTALLDIR}/lib/
# make clean
make
make install
cd ${SRCDIR}/${ZLIB}
./configure --shared --prefix=${INSTALLDIR}
# make clean
make
make install
cd ${SRCDIR}/${LIBMCRYPT}
./configure --disable-posix-threads --prefix=${INSTALLDIR}
# make clean
make
make install
cd ${SRCDIR}/${LIBMCRYPT}/libltdl
./configure --prefix=${INSTALLDIR} --enable-ltdl-install
make
make install
cd ${SRCDIR}/${MHASH}
./configure --prefix=${INSTALLDIR}
# make clean
make
make install
cd ${SRCDIR}/${LIBIDN}
./configure --with-iconv-prefix=${INSTALLDIR} --prefix=${INSTALLDIR}
# make clean
make
make install
cd ${SRCDIR}/${CURL}
./configure --with-ssl=${INSTALLDIR} --with-zlib=${INSTALLDIR} \
--with-libidn=${INSTALLDIR} --enable-ipv6 --enable-cookies \
--enable-crypto-auth --prefix=${INSTALLDIR}
# make clean
make
make install
cd ${SRCDIR}/${CCLIENT_DIR}
make ldb
# Install targets are for wusses!
cp c-client/c-client.a ${INSTALLDIR}/lib/libc-client.a
cp c-client/*.h ${INSTALLDIR}/include
cd ${SRCDIR}/${PHP5}
./configure ${PHPFEATURES}
# make clean
make
make install
# End the big build
# Begin the big configure
#copy config file
mkdir -p ${INSTALLDIR}/etc/ ;
cp ${SRCDIR}/${PHP5}/php.ini-dist ${INSTALLDIR}/etc/php.ini
#copy PHP CGI and configure installation
echo 'Configuring the final install for the user'
mkdir -p /home/${USER}/public_html/cgi-bin
chmod 0755 /home/${USER}/public_html/cgi-bin
cp ${INSTALLDIR}/bin/php /home/${USER}/public_html/cgi-bin/php.cgi
chmod 755 /home/${USER}/public_html/cgi-bin/php.cgi
chown ${USER} /home/${USER}/public_html/cgi-bin/php.cgi
chown -R ${USER} /home/${USER}/php5/*
chgrp -R ${USER} /home/${USER}/public_html/cgi-bin/
chown -R ${USER} /home/${USER}/php5/etc
chgrp -R ${USER} /home/${USER}/php5/etc
#Make a config file
touch /home/${USER}/public_html/.htaccess
echo '#This is the bit that makes php5 work' >> /home/${USER}/public_html/.htaccess
echo 'AddHandler phpFive .php' >> /home/${USER}/public_html/.htaccess
echo 'Action phpFive /cgi-bin/php.cgi' >> /home/${USER}/public_html/.htaccess
# Install Zend Optimizer on this installation
echo 'Installing Zend Optimizer and Extension Manager'
touch /home/${USER}/php5/etc/php.ini
echo '[Zend]' >> /home/${USER}/php5/etc/php.ini
echo 'zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.0.0' >> /home/${USER}/php5/etc/php.ini
echo 'zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.0.0' >> /home/${USER}/php5/etc/php.ini
echo 'zend_optimizer.version=3.0.0' >> /home/${USER}/php5/etc/php.ini
echo 'zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so' >>/home/${USER}/php5/etc/php.ini
echo 'zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so' >>/home/${USER}/php5/etc/php.ini
echo 'Done with Zend'
# End the big configure
# Cleanup
echo 'Cleaning up'
rm -rf /home/${USER}/source
rm -rf /home/${USER}/dist
#Final notice
echo 'PHP5 is now available for this user'
echo 'The php5 binaries installed will now be used to execute all php on this users domain'
WHM said:fpshosting I recommend you dual run PHP4 and PHP5 so on signup clients have a choice of which PHP version they get to use. It will help expand your offerings.
Billy