PHP 5 install script/dev

PHP5 Install Script
This version includes some advanced "dummy proof" error checking. It also allows for, to some degree, updating older custom installs if they exist.

Unfortunately it's quite long, so if you're able to find ways to shorten it by all means please do!

Mousee 09:08, 30 May 2007 (PDT)

php5install.sh
set -e
 * 1) !/bin/sh


 * 1) Version 0.6e, 2007-10-05
 * 2) - Updated 2007-09-19 by Chris Shymanik (chris@chipsncheese.com)
 * 3)   - Updated to the latest PHP5 (5.2.4) and verified that it works.
 * 4)   - Updates to depedencies:
 * 5)         Curl (7.16.2 -> 7.17.0), freetype (2.3.4 -> 2.3.5), libxslt (1.1.20 -> 1.1.22)
 * 6)   - Minor revision 0.6d to fix an end-of-install bug.
 * 7) - Updated 2007-06-08 by Chris Shymanik (chris@chipsncheese.com)
 * 8)   - Will backup and re-install any old php.ini's found (see notes in wiki about this).
 * 9)   - Source file detection.
 * 10)   - Allows cgi-bin to be installed in a sub-directory (EXTDIR)
 * 11)   - Created steps as functions, for easier troubleshooting/modification.
 * 12)   - Updated various packages and did some additional code cleanup.
 * 13)   - OSSP mm (Shared Memory Allocation) and bzip2 packages added.
 * 14)   - Changed which binary to use, based on the new location in PHP 5.2.3.
 * 15) - Updated 2007-01-15 by Charles Wiltgen (charles@wiltgen.net)
 * 16)   - Make "nicer" to help keep it from getting killed by DreamHost
 * 17)   - Make less verbose to keep signal-to-noise level high
 * 18) - Updated 2006-12-25 by Carl McDade (hiveminds.co.uk)
 * 19)   - Allow memory limit and freetype
 * 1)   - Allow memory limit and freetype

function config_env { export DOMAIN="mydomain.tld" SRCDIR=${HOME}/source DISTDIR=${HOME}/dist DISTDEL="No" BACKUPDIR=${HOME}/php5tmp INSTALLDIR=${HOME}/php5 EXTYESNO="No" EXTDIR=main NICE=19 }
 * 1) User Configuration Options
 * 2) Domain & Directory Configuration
 * 3) Domain to install to
 * 1) Temporary source directory
 * 1) Download temporary DIST files to which directory?
 * 1) Delete contents of DISTDIR after installation? (Default: No)
 * 1) Backup your previous php.ini files to which directory (if any)?
 * 2) Please Note: You'll need to remove this directory manually if it's used.
 * 3) (!!You MUST use a trailing slash when specifying this directive!!)
 * 1) Install PHP5 to which directory?
 * 1) Install PHP5's cgi-bin files to a directory besides home?
 * 2)    ie.: /home/username/mywebsite.com/sub/level/directory
 * 1) Directory under home in which the cgi-bin files will be installed to
 * 2)    ie.: /sub/level/directory
 * 1) Nice Level for Processes. (Deprecated)
 * 2) Higher is nicer, lower is less nice and could get your install process killed!

PHP5="php-5.2.4" LIBICONV="libiconv-1.11" LIBMCRYPT="libmcrypt-2.5.8" LIBXML2="libxml2-2.6.28" LIBXSLT="libxslt-1.1.22" MHASH="mhash-0.9.9" ZLIB="zlib-1.2.3" BZIP2="bzip2-1.0.4" CURL="curl-7.17.0" LIBIDN="libidn-0.6.9" CCLIENT="imap-2004g" CCLIENT_DIR="imap-2004g" FREETYPE="freetype-2.3.5" MM="mm-1.4.0"
 * 1) Program Version Configuration
 * 2) Don't touch unless you know what you're doing!

config_env
 * 1) END User Configuration Options


 * 1) Advanced PHP Features Options
 * 2) Don't touch unless you know what you're doing!

PHPFEATURES="--prefix=${INSTALLDIR} \ --with-config-file-path=${INSTALLDIR}/etc/php5/${DOMAIN} \ --enable-fastcgi \ --enable-force-cgi-redirect \ --with-xml \ --with-xmlrpc \ --with-libxml-dir=${INSTALLDIR} \ --with-freetype-dir=${INSTALLDIR} \ --enable-soap \ --with-openssl=/usr \ --with-mhash=${INSTALLDIR} \ --with-mcrypt=${INSTALLDIR} \ --with-zlib-dir=${INSTALLDIR} \ --with-bz2=${INSTALLDIR} \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --with-gd \ --enable-gd-native-ttf \ --enable-memory-limit \ --with-mm=${INSTALLDIR} \ --enable-ftp \ --with-exif \ --enable-exif \ --enable-sockets \ --enable-wddx \ --with-iconv=${INSTALLDIR} \ --enable-sqlite-utf8 \ --enable-calendar \ --with-curl=${INSTALLDIR} \ --enable-mbstring \ --enable-mbregex \ --with-mysql=/usr \ --with-mysqli \ --without-pear \ --with-gettext \ --with-imap=${INSTALLDIR} \ --with-imap-ssl=/usr"


 * 1) END Advanced PHP Features Options

sleep 1s
 * 1) DO NOT MODIFY BELOW ##########

function check_prepare { export PATH=${INSTALLDIR}/bin:$PATH
 * 1) Function to check for an existing install.
 * 1) Push the install dir's bin directory into the path

echo "Installation commencing..." `date +%r` echo ""
 * 1) Indicate the time at which the install started.

if [ -d ${INSTALLDIR}/etc/php5 ]; then echo "--- Backing up php.ini file..." mkdir -p ${BACKUPDIR} cp -R ${INSTALLDIR}/etc/php5/* ${BACKUPDIR}/ echo "Done." else echo "No php.ini will be backed-up during this update!" fi if [ -d ${INSTALLDIR} ] then # Check for a running process #	Note: This is only a very basic detect & kill system. if [ "$(ps aux | grep -q php5.fcgi)" == "php5.fcgi" ] then while [ "$(ps aux | grep -q php5.fcgi)" == "php5.fcgi" ] do					 kill -9 php5.fcgi sleep 5s done fi echo "Install directory exists! Killing active processes and clearing it..." rm -rf ${INSTALLDIR} else echo "Install directory check complete." fi if [ -d ${HOME}/${DOMAIN}/cgi-bin ]; then echo "cgi-bin directory exists! Clearing contents..." rm -rf ${HOME}/${DOMAIN}/cgi-bin else echo "cgi-bin directory check complete." fi }
 * 1) Backup previous php.ini file(s) if exist.
 * 1) Check for existing php5 install, kill any running processes from it, and remove.
 * 2) 	Note: This is only for fast-cgi processes. This should probably be modified
 * 3) 		to detect other custom php5 processes for a fully functional script.
 * 1) Remove the existing cgi-bin directory.

function chkproc_paths { cores=2  # the number of cores/procs to use when building if [ $cores -a $cores -gt 1 ]; then j="-j$cores " fi OS=`uname -s` if [ "Darwin" = $OS ]; then sed=gnused makefile=makefile.macosx else makefile=makefile.linux_x86_ppc_alpha sed=sed fi for i in $sed wget; do		 $i --version >/dev/null 2>&1 done
 * 1) Function to check for and setup the appropriate paths.
 * 1) Detect how many processors the system has (for more optimal compliation).

if [ -d ${SRCDIR} ]; then echo "Source directory already exists! Cleaning it..." rm -rf $SRCDIR/* else echo "Creating source directory..." mkdir -p ${SRCDIR} fi if [ -d ${DISTDIR} ]; then echo ""; echo "Distribution directory already exists!"; echo "Clean it?" if [ ${DISTDEL} == "Yes" ] then echo ""; echo "Yes!"; echo "Cleaning now..."; echo "" rm -rf $DISTDIR/* else echo ""; echo "No!"; echo "Leaving the distribution directory intact."; echo "" fi else echo "Creating distribution directory..." mkdir -p ${DISTDIR} fi }
 * 1) Clear and/or create the source directory.
 * 1) Create the dist files directory if it doesn't exist
 * 2) optionally cleaning it if it does exist already.

function wget_source { set +e cd ${DISTDIR} WGETOPT="-t1 -T10 -w5 -q -c"
 * 1) Function to get the required source files.
 * 2) 	Note: Some future checking is required to ensure the primary mirror
 * 3) 		is valid and use an alternative mirror if not.
 * 1) Wget options

if [ -a ${DISTDIR}/${PHP5}.tar.bz2 ]; then echo "Skipping wget of ${PHP5}.tar.bz2" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${PHP5}.tar.bz2 # If primary mirror fails, use the alternative mirror. if [ -a ${DISTDIR}/${PHP5}.tar.bz2 ]; then echo "Got ${PHP5}.tar.bz2" else wget $WGETOPT http://us3.php.net/distributions/${PHP5}.tar.gz # Check to make sure the alternative mirror worked. if [ -a ${DISTDIR}/${PHP5}.tar.gz ]; then echo "Got ${PHP5}.tar.gz" else echo "Failed to get ${PHP5}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${LIBICONV}.tar.gz ]; then echo "Skipping wget of ${LIBICONV}.tar.gz" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${LIBICONV}.tar.gz		 if [ -a ${DISTDIR}/${LIBICONV}.tar.gz ]; then echo "Got ${LIBICONV}.tar.gz" else wget $WGETOPT http://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz				if [ -a ${DISTDIR}/${LIBICONV}.tar.gz ]; then echo "Got ${LIBICONV}.tar.gz" else echo "Failed to get ${LIBICONV}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${LIBMCRYPT}.tar.gz ]; then echo "Skipping wget of ${LIBMCRYPT}.tar.gz" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${LIBMCRYPT}.tar.gz		 if [ -a ${DISTDIR}/${LIBMCRYPT}.tar.gz ]; then echo "Got ${LIBMCRYPT}.tar.gz" else wget $WGETOPT http://umn.dl.sourceforge.net/sourceforge/mcrypt/${LIBMCRYPT}.tar.gz				if [ -a ${DISTDIR}/${LIBMCRYPT}.tar.gz ]; then echo "Got ${LIBMCRYPT}.tar.gz" else echo "Failed to get ${LIBMCRYPT}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${LIBXML2}.tar.gz ]; then echo "Skipping wget of ${LIBXML2}.tar.gz" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${LIBXML2}.tar.gz		 if [ -a ${DISTDIR}/${LIBXML2}.tar.gz ]; then echo "Got ${LIBXML2}.tar.gz" else wget $WGETOPT ftp://xmlsoft.org/libxml2/${LIBXML2}.tar.gz				if [ -a ${DISTDIR}/${LIBXML2}.tar.gz ]; then echo "Got ${LIBXML2}.tar.gz" else echo "Failed to get ${LIBXML2}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${LIBXSLT}.tar.gz ]; then echo "Skipping wget of ${LIBXSLT}.tar.gz" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${LIBXSLT}.tar.gz		 if [ -a ${DISTDIR}/${LIBXSLT}.tar.gz ]; then echo "Got ${LIBXSLT}.tar.gz" else wget $WGETOPT ftp://xmlsoft.org/libxml2/${LIBXSLT}.tar.gz				if [ -a ${DISTDIR}/${LIBXSLT}.tar.gz ]; then echo "Got ${LIBXSLT}.tar.gz" else echo "Failed to get ${LIBXSLT}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${MHASH}.tar.gz ]; then echo "Skipping wget of ${MHASH}.tar.gz" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${MHASH}.tar.gz		 if [ -a ${DISTDIR}/${MHASH}.tar.gz ]; then echo "Got ${MHASH}.tar.gz" else wget $WGETOPT http://umn.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz				if [ -a ${DISTDIR}/${MHASH}.tar.gz ]; then echo "Got ${MHASH}.tar.gz" else echo "Failed to get ${MHASH}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${ZLIB}.tar.bz2 ]; then echo "Skipping wget of ${ZLIB}.tar.bz2" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${ZLIB}.tar.bz2 if [ -a ${DISTDIR}/${ZLIB}.tar.bz2 ]; then echo "Got ${ZLIB}.tar.bz2" else wget $WGETOPT http://www.zlib.net/${ZLIB}.tar.gz				if [ -a ${DISTDIR}/${ZLIB}.tar.gz ]; then echo "Got ${ZLIB}.tar.gz" else echo "Failed to get ${ZLIB}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${BZIP2}.tar.gz ]; then echo "Skipping wget of ${BZIP2}.tar.gz" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${BZIP2}.tar.gz		 if [ -a ${DISTDIR}/${BZIP2}.tar.gz ]; then echo "Got ${BZIP2}.tar.gz" else wget $WGETOPT http://www.bzip.org/1.0.3/${BZIP2}.tar.gz				if [ -a ${DISTDIR}/${BZIP2}.tar.gz ]; then echo "Got ${BZIP2}.tar.gz" else echo "Failed to get ${ZLIB}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${MM}.tar.gz ]; then echo "Skipping wget of ${MM}.tar.gz" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${MM}.tar.gz		 if [ -a ${DISTDIR}/${MM}.tar.gz ]; then echo "Got ${MM}.tar.gz" else wget $WGETOPT ftp://ftp.ossp.org/pkg/lib/mm/${MM}.tar.gz				if [ -a ${DISTDIR}/${MM}.tar.gz ]; then echo "Got ${MM}.tar.gz" else echo "Failed to get ${MM}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${CURL}.tar.bz2 ]; then echo "Skipping wget of ${CURL}.tar.bz2" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${CURL}.tar.bz2 if [ -a ${DISTDIR}/${CURL}.tar.bz2 ]; then echo "Got ${CURL}.tar.bz2" else wget $WGETOPT http://curl.haxx.se/download/${CURL}.tar.gz				if [ -a ${DISTDIR}/${CURL}.tar.gz ]; then echo "Got ${CURL}.tar.gz" else echo "Failed to get ${CURL}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${FREETYPE}.tar.bz2 ]; then echo "Skipping wget of ${FREETYPE}.tar.bz2" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${FREETYPE}.tar.bz2 if [ -a ${DISTDIR}/${FREETYPE}.tar.bz2 ]; then echo "Got ${FREETYPE}.tar.bz2" else wget $WGETOPT http://umn.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz				if [ -a ${DISTDIR}/${FREETYPE}.tar.bz2 ]; then echo "Got ${FREETYPE}.tar.bz2" else echo "Failed to get ${CURL}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${LIBIDN}.tar.gz ]; then echo "Skipping wget of ${LIBIDN}.tar.gz" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${LIBIDN}.tar.gz		 if [ -a ${DISTDIR}/${LIBIDN}.tar.gz ]; then echo "Got ${LIBIDN}.tar.gz" else wget $WGETOPT ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz				if [ -a ${DISTDIR}/${LIBIDN}.tar.gz ]; then echo "Got ${LIBIDN}.tar.gz" else echo "Failed to get ${CURL}.tar.gz. Aborting install!" exit 0 fi fi fi if [ -a ${DISTDIR}/${CCLIENT}.tar.Z ]; then echo "Skipping wget of ${CCLIENT}.tar.Z" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${CCLIENT}.tar.Z		 if [ -a ${DISTDIR}/${CCLIENT}.tar.Z ]; then echo "Got ${CCLIENT}.tar.Z"		 else wget $WGETOPT ftp://ftp.cac.washington.edu/imap/old/${CCLIENT}.tar.Z				if [ -a ${DISTDIR}/${CCLIENT}.tar.Z ]; then echo "Got ${CCLIENT}.tar.Z"				else echo "Failed to get ${CCLIENT}.tar.Z. Aborting install!" exit 0 fi fi fi set -e }
 * 1) Check if packages already exist and get packages the ones that don't.

function extract_source { cd ${SRCDIR} echo "Extracting ${PHP5}..." if [ -a ${DISTDIR}/${PHP5}.tar.bz2 ]; then tar xjf ${DISTDIR}/${PHP5}.tar.bz2 > /dev/null else tar xzf ${DISTDIR}/${PHP5}.tar.gz > /dev/null fi echo "Done." echo "Extracting ${LIBICONV}..." tar xzf ${DISTDIR}/${LIBICONV}.tar.gz > /dev/null echo "Done." echo "Extracting ${LIBMCRYPT}..." tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz > /dev/null echo "Done." echo "Extracting ${LIBXML2}..." tar xzf ${DISTDIR}/${LIBXML2}.tar.gz > /dev/null echo "Done." echo "Extracting ${LIBXSLT}..." tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz > /dev/null echo "Done." echo "Extracting ${MHASH}..." tar xzf ${DISTDIR}/${MHASH}.tar.gz > /dev/null echo "Done." echo "Extracting ${ZLIB}..." if [ -a ${DISTDIR}/${ZLIB}.tar.bz2 ]; then tar xjf ${DISTDIR}/${ZLIB}.tar.bz2 > /dev/null else tar xzf ${DISTDIR}/${ZLIB}.tar.gz > /dev/null fi echo "Done." echo "Extracting ${BZIP2}..." tar xzf ${DISTDIR}/${BZIP2}.tar.gz > /dev/null echo "Done." echo "Extracting ${MM}..." tar xzf ${DISTDIR}/${MM}.tar.gz > /dev/null echo "Done." echo "Extracting ${CURL}..." if [ -a ${DISTDIR}/${CURL}.tar.bz2 ]; then tar xjf ${DISTDIR}/${CURL}.tar.bz2 > /dev/null else tar xzf ${DISTDIR}/${CURL}.tar.gz > /dev/null fi echo "Done." echo "Extracting ${FREETYPE}..." if [ -a ${DISTDIR}/${FREETYPE}.tar.bz2 ]; then tar xjf ${DISTDIR}/${FREETYPE}.tar.bz2 > /dev/null else tar xzf ${DISTDIR}/${FREETYPE}.tar.gz > /dev/null fi echo "Done." echo "Extracting ${LIBIDN}..." tar xzf ${DISTDIR}/${LIBIDN}.tar.gz > /dev/null echo "Done." echo "Extracting ${CCLIENT}..." uncompress -cd ${DISTDIR}/${CCLIENT}.tar.Z |tar x echo "Done." }
 * 1) Function to extract all the source files into the source directory.

function configsrc_install { echo --- Configuring PHP5 and dependencies... cd ${SRCDIR}/${LIBICONV} ./configure --enable-extra-encodings --prefix=${INSTALLDIR} nice -n ${NICE} make make install
 * 1) Function to compile and install the packages.

cd ${SRCDIR}/${LIBXML2} ./configure --with-iconv=${INSTALLDIR} --prefix=${INSTALLDIR} nice -n ${NICE} 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/ nice -n ${NICE} make make install

cd ${SRCDIR}/${ZLIB} ./configure --shared --prefix=${INSTALLDIR} nice -n ${NICE} make make install

cd ${SRCDIR}/${BZIP2} nice -n ${NICE} make make install PREFIX=${INSTALLDIR}

cd ${SRCDIR}/${MM} ./configure --prefix=${INSTALLDIR} nice -n ${NICE} make make install PREFIX=${INSTALLDIR}

cd ${SRCDIR}/${LIBMCRYPT} ./configure --disable-posix-threads --prefix=${INSTALLDIR} nice -n ${NICE} make make install

cd ${SRCDIR}/${LIBMCRYPT}/libltdl ./configure --prefix=${INSTALLDIR} --enable-ltdl-install nice -n ${NICE} make make install

cd ${SRCDIR}/${MHASH} ./configure --prefix=${INSTALLDIR} nice -n ${NICE} make make install

cd ${SRCDIR}/${FREETYPE} ./configure --prefix=${INSTALLDIR} nice -n ${NICE} make make install

cd ${SRCDIR}/${LIBIDN} ./configure --with-iconv-prefix=${INSTALLDIR} --prefix=${INSTALLDIR} nice -n ${NICE} 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} nice -n ${NICE} make make install

cd ${SRCDIR}/${CCLIENT_DIR} make ldb cp c-client/c-client.a ${INSTALLDIR}/lib/libc-client.a cp c-client/*.h ${INSTALLDIR}/include

cd ${SRCDIR}/${PHP5} ./configure ${PHPFEATURES} nice -n ${NICE} make make install }

function php_postinstall { config_env
 * 1) Function for post install actions.

if [ -d ${BACKUPDIR} ]; then echo "Restoring old php.ini configuration" cp -R ${BACKUPDIR}/* ${INSTALLDIR}/etc/php5/ mv ${SRCDIR}/${PHP5}/php.ini-dist ${INSTALLDIR}/etc/php5/${DOMAIN}/php.ini-dist else echo "No previous php.ini to restore." mkdir -p ${INSTALLDIR}/etc/php5/${DOMAIN} cp ${SRCDIR}/${PHP5}/php.ini-dist ${INSTALLDIR}/etc/php5/${DOMAIN}/php.ini fi
 * 1) Restore the old php.ini if available and rename the default.

if [ ${EXTYESNO} == "Yes" ] then if [ -d ${HOME}/${DOMAIN}/${EXTDIR}/cgi-bin ] then echo "cgi-bin directory exists! Doing nothing..." else mkdir -p ${HOME}/${DOMAIN}/${EXTDIR}/cgi-bin chmod 0755 ${HOME}/${DOMAIN}/${EXTDIR}/cgi-bin fi else if [ -d ${HOME}/${DOMAIN}/cgi-bin ] then echo "cgi-bin directory exists! Doing nothing..." else mkdir -p ${HOME}/${DOMAIN}/cgi-bin chmod 0755 ${HOME}/${DOMAIN}/cgi-bin fi fi if [ ${EXTYESNO} == "Yes" ]; then cp ${INSTALLDIR}/bin/php-cgi ${HOME}/${DOMAIN}/${EXTDIR}/cgi-bin/php.cgi cp ${INSTALLDIR}/bin/php-cgi ${HOME}/${DOMAIN}/${EXTDIR}/cgi-bin/php5.fcgi else cp ${INSTALLDIR}/bin/php-cgi ${HOME}/${DOMAIN}/cgi-bin/php.cgi cp ${INSTALLDIR}/bin/php-cgi ${HOME}/${DOMAIN}/cgi-bin/php5.fcgi fi echo "Striping debug info from cgi-bin files..." strip --strip-all ${HOME}/${DOMAIN}/cgi-bin/php.cgi strip --strip-all ${HOME}/${DOMAIN}/cgi-bin/php5.fcgi }

function postinstall_cleanup { sleep 2s cd ${HOME} && clear echo "Post-Install clean-up..."
 * 1) Function for post install cleanup.

rm -rf $SRCDIR if [ ${DISTDEL} == "Yes" ]; then rm -rf $DISTDIR elif [ ${DISTDEL} == "No" ]; then echo "Your DISTDIR will not be cleaned." else echo "Unknown DISTDEL option! Preserving your DISTDIR by default." fi }

check_prepare chkproc_paths wget_source extract_source configsrc_install php_postinstall postinstall_cleanup
 * 1) Prepare the environemnt to install PHP5 & Extras
 * 1) Check to ensure the install paths are created and correct
 * 1) Wget the sources for extraction
 * 1) Extract the sources
 * 1) Configure the source code and Install it
 * 1) Misc. PHP installation steps (Post Install)
 * 1) Cleanup the environment of items we no longer need

echo "Installation completed!" `date +%r` echo "" echo "Remember to edit your .htaccess file now!"
 * 1) End of Install
 * 2) Tell the user we're done.


 * EOF

Using CGI/FCGI through .htaccess
The following are just examples, but certainly may be modified or used in any way you'd like. Just append the snippet below to your .htccess file (Note: This ASSUMES you know what you're doing. Please use the discussion page if you have questions about editing your .htaccess file).

CGI Example
AddHandler cgi-script .cgi AddHandler php-cgi .php Action php-cgi /cgi-bin/php.cgi
 * 1) Normal CGI

FCGI Example
AddHandler fastcgi-script fcgi fcg fpl AddHandler php5-fastcgi .php Action php5-fastcgi /php5-wrapper.fcgi
 * 1) FastCGI

You'll also need to create the php5-wrapper.fcgi (or dispatch.fcgi) script, which should look something to the following: export PHPRC=~/php5/etc/php5/mydomain.tld export PHP_FCGI_CHILDREN=2 exec ~/mydomain.tld/cgi-bin/php5.fcgi
 * 1) !/bin/sh

While it's recommended you place this file in the root of your domain (ie. /home/username/mydomain.tld/php5-wrapper.fcgi), you may place it anywhere under your domain, so long as your .htaccess is pointing to its location and it is executable (chmod +x).