Difference between revisions of "PHP 5 install script"

From DreamHost
Jump to: navigation, search
(Updated, now on to the main script)
m (Undo revision 19187 by Special:Contributions/Cduke250 (User talk:Cduke250) - Inappropriate links to external (personal) site.)
Line 268: Line 268:
 
#!/bin/sh
 
#!/bin/sh
  
# Version 0.6, 2007-12-16
+
# Version 0.5, 2007-01-15
 
#
 
#
# - Updated 2007-12-16 by AskApache (www.askapache.com)
 
#  - Implemented functions to fetch the URI and decompress it
 
#  - Added a couple more error-checks
 
#  - Replaced wget with cURL
 
#  - Added more to help keep it from getting killed
 
#  - Updated to php-5.2.3, curl-7.17.1, freetype-2.3.5
 
 
# - Updated 2007-01-15 by Charles Wiltgen (charles@wiltgen.net)
 
# - Updated 2007-01-15 by Charles Wiltgen (charles@wiltgen.net)
 
#  - Make "nicer" to help keep it from getting killed by DreamHost
 
#  - Make "nicer" to help keep it from getting killed by DreamHost
Line 281: Line 275:
 
# - Updated 2006-12-25 by Carl McDade (hiveminds.co.uk)
 
# - Updated 2006-12-25 by Carl McDade (hiveminds.co.uk)
 
#  - Allow memory limit and freetype
 
#  - Allow memory limit and freetype
 +
 +
echo php5-install-prep.sh
 +
echo - This script downloads and unpacks all prerequisite packages
 +
echo - Run this script before php5-install.sh
 +
echo
 +
read -p  "(Press any key to continue)" temp;
 +
echo
  
 
# Abort on any errors
 
# Abort on any errors
Line 286: Line 287:
  
 
# The domain in which to install the PHP CGI script.
 
# The domain in which to install the PHP CGI script.
export DOMAIN="your-domain-root.com"
+
export DOMAIN="your-domain-here.com"
  
# Where do you want all this stuff built? I'd recommend picking a local filesystem.
+
# Where do you want all this stuff built? I'd recommend picking a local
# ***Don't pick a directory that already exists!***
+
# filesystem.
 +
# ***Don't pick a directory that already exists!*** We clean up after
 +
# ourselves at the end!
 
SRCDIR=${HOME}/source
 
SRCDIR=${HOME}/source
  
Line 298: Line 301:
 
# script and run it several times!
 
# script and run it several times!
 
DISTDIR=${HOME}/dist
 
DISTDIR=${HOME}/dist
 
  
 
# Update version information here.
 
# Update version information here.
PHP5="php-5.2.3"
+
PHP5="php-5.2.0"
 
LIBICONV="libiconv-1.11"
 
LIBICONV="libiconv-1.11"
 
LIBMCRYPT="libmcrypt-2.5.7"
 
LIBMCRYPT="libmcrypt-2.5.7"
Line 308: Line 310:
 
MHASH="mhash-0.9.7.1"
 
MHASH="mhash-0.9.7.1"
 
ZLIB="zlib-1.2.3"
 
ZLIB="zlib-1.2.3"
CURL="curl-7.17.1"
+
CURL="curl-7.14.0"
 
LIBIDN="libidn-0.6.8"
 
LIBIDN="libidn-0.6.8"
 
CCLIENT="imap-2004g"
 
CCLIENT="imap-2004g"
CCLIENT_DIR="imap-2004g"
+
CCLIENT_DIR="imap-2004g" # Another pest!
FREETYPE="freetype-2.3.5"
+
FREETYPE="freetype-2.2.1"
  
# Push the install dir's bin directory into the path
 
export PATH=${INSTALLDIR}/bin:$PATH
 
 
 
function aa_unpack () {
 
# compressed, tar and gzip files to DISTDIR
 
if [ -f $DISTDIR/$1* ] ; then
 
echo Extracting "$1";
 
zcat ${DISTDIR}/$1* | tar -xvf - &>/dev/null;
 
echo Done.; echo; wait
 
fi
 
}
 
 
 
function askapache_grab () {
 
#saves file to SRCDIR
 
    echo `basename $1`
 
curl -L --retry 20 --max-time 1800 --retry-delay 30 -# -f --max-redirs 4 --remote-name "$1"
 
}
 
 
 
echo
 
echo --------------------------------------------------
 
echo --  Run this script before php5-install.sh    --
 
echo --------------------------------------------------
 
 
echo
 
echo
echo - Downloads and unpacks all prerequisite packages
+
echo --- Cleaning up any previous attempts
echo - **SRCDIR and DISTDIR will be deleted**
+
 
echo
 
echo
read -p  "        (Press any key to continue)" temp;
 
echo;echo
 
  
# cleanup to remove source and dist directories if present
+
# Pre-prep cleanup
if [ -d "$SRCDIR" ] || [ -d "$DISTDIR" ];then
+
rm -rf $SRCDIR $DISTDIR
echo
+
echo --- Cleaning up any previous attempts ---
+
rm -rf $SRCDIR $DISTDIR &>/dev/null
+
echo Done.
+
echo
+
wait
+
fi
+
  
 +
# Push the install dir's bin directory into the path
 +
export PATH=${INSTALLDIR}/bin:$PATH
  
 
#setup directories
 
#setup directories
mkdir -p ${SRCDIR} ${INSTALLDIR} ${DISTDIR} &>/dev/null
+
mkdir -p ${SRCDIR}
 +
mkdir -p ${INSTALLDIR}
 +
mkdir -p ${DISTDIR}
 +
cd ${DISTDIR}
  
 
# Get all the required packages
 
# Get all the required packages
echo;echo
+
echo
 
echo --- Downloading all required packages ---
 
echo --- Downloading all required packages ---
 
echo
 
echo
  
cd ${DISTDIR}
+
wget -c http://us.php.net/distributions/${PHP5}.tar.gz
askapache_grab http://us.php.net/distributions/${PHP5}.tar.gz
+
wget -c http://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz
askapache_grab http://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz
+
wget -c http://umn.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.7.tar.gz
askapache_grab http://umn.dl.sourceforge.net/sourceforge/mcrypt/${LIBMCRYPT}.tar.gz
+
wget -c ftp://xmlsoft.org/libxml2/${LIBXML2}.tar.gz
askapache_grab ftp://xmlsoft.org/libxml2/${LIBXML2}.tar.gz
+
wget -c ftp://xmlsoft.org/libxml2/${LIBXSLT}.tar.gz
askapache_grab ftp://xmlsoft.org/libxml2/${LIBXSLT}.tar.gz
+
wget -c http://umn.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz
askapache_grab http://umn.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz
+
wget -c http://www.zlib.net/${ZLIB}.tar.gz
askapache_grab http://www.zlib.net/${ZLIB}.tar.gz
+
wget -c http://curl.haxx.se/download/${CURL}.tar.gz
askapache_grab http://curl.askapache.com/download/${CURL}.tar.gz
+
wget -c http://umn.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz
askapache_grab http://easynews.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz
+
wget -c ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
askapache_grab ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
+
wget -c ftp://ftp.cac.washington.edu/imap/old/${CCLIENT}.tar.Z
askapache_grab ftp://ftp.cac.washington.edu/imap/old/${CCLIENT}.tar.Z
+
wait
+
echo Done.
+
  
 
+
echo
# Extract the files from the required packages.
+
echo;echo;echo
+
 
echo --- Unpacking downloaded archives. This process may take several minutes! ---
 
echo --- Unpacking downloaded archives. This process may take several minutes! ---
 
echo
 
echo
  
 
cd ${SRCDIR}
 
cd ${SRCDIR}
aa_unpack ${PHP5}
+
# Unpack them all
aa_unpack ${LIBICONV}
+
echo Extracting ${PHP5}...
aa_unpack ${LIBMCRYPT}
+
tar xzf ${DISTDIR}/${PHP5}.tar.gz > /dev/null
aa_unpack ${LIBXML2}
+
echo Done.
aa_unpack ${LIBXSLT}
+
echo Extracting ${LIBICONV}...
aa_unpack ${MHASH}
+
tar xzf ${DISTDIR}/${LIBICONV}.tar.gz > /dev/null
aa_unpack ${ZLIB}
+
echo Done.
aa_unpack ${CURL}
+
echo Extracting ${LIBMCRYPT}...
aa_unpack ${LIBIDN}
+
tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz > /dev/null
aa_unpack ${CCLIENT}
+
echo Done.
aa_unpack ${FREETYPE}
+
echo Extracting ${LIBXML2}...
wait
+
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}...
 +
tar xzf ${DISTDIR}/${ZLIB}.tar.gz > /dev/null
 +
echo Done.
 +
echo Extracting ${CURL}...
 +
tar xzf ${DISTDIR}/${CURL}.tar.gz > /dev/null
 +
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.
 +
echo Extracting ${FREETYPE}...
 +
tar xzf ${DISTDIR}/${FREETYPE}.tar.gz > /dev/null
 +
echo Done.
  
 
echo --------------------------------------------------
 
echo --------------------------------------------------
 
echo -- Done downloading and unpacking prerequisites --
 
echo -- Done downloading and unpacking prerequisites --
 
echo --------------------------------------------------
 
echo --------------------------------------------------
 
exit 0;
 
 
</pre>
 
</pre>
  

Revision as of 19:14, 16 December 2007

read this first: Installing PHP5

Main PHP 5 install script

This is the "main" PHP 5 install script. (Below it is a more-recent, alternate PHP 5 install script that may help users who find that the script keeps getting automatically "killed" by DreamHost.)

This script does not work if you are compiling PHP version 5.2.3 or greater. To make this script work when compiling PHP version 5.2.3 or greater, change the third from last line from this...

cp ${INSTALLDIR}/bin/php ${HOME}/${DOMAIN}/cgi-bin/php.cgi

...to this...

cp ${INSTALLDIR}/bin/php-cgi ${HOME}/${DOMAIN}/cgi-bin/php.cgi
#!/bin/sh

# Script updated 2006-12-25 by Carl McDade (hiveminds.co.uk) to allow memory limit and freetype
#
# Script updated 2007-11-24 by Andrew (ajmconsulting.net) to allow 3rd wget line to pass 
# LIBMCRYPT version information (was set as static download file name previously.)
#
# Save the code to a file as *.sh
# Abort on any errors
#
set -e

# The domain in which to install the PHP CGI script.
export DOMAIN="your.domain.com"

# Where do you want all this stuff built? I'd recommend picking a local
# filesystem.
# ***Don't pick a directory that already exists!***  We clean up after
# ourselves at the end!
SRCDIR=${HOME}/source

# And where should it be installed?
INSTALLDIR=${HOME}/php5

# Set DISTDIR to somewhere persistent, if you plan to muck around with this
# script and run it several times!
DISTDIR=${HOME}/dist

# Pre-download clean up!!!!
rm -rf $SRCDIR $DISTDIR

# Update version information here.
PHP5="php-5.2.0"
LIBICONV="libiconv-1.11"
LIBMCRYPT="libmcrypt-2.5.7"
LIBXML2="libxml2-2.6.27"
LIBXSLT="libxslt-1.1.18"
MHASH="mhash-0.9.7.1"
ZLIB="zlib-1.2.3"
CURL="curl-7.14.0"
LIBIDN="libidn-0.6.8"
CCLIENT="imap-2004g"
CCLIENT_DIR="imap-2004g" # Another pest!
FREETYPE="freetype-2.2.1"

# What PHP features do you want enabled?
PHPFEATURES="--prefix=${INSTALLDIR} \
 --with-config-file-path=${INSTALLDIR}/etc/php5/${DOMAIN} \
 --enable-fastcgi \
 --enable-force-cgi-redirect \
 --with-xml \
 --with-libxml-dir=${INSTALLDIR} \
 --with-freetype-dir=${INSTALLDIR} \
 --enable-soap \
 --with-openssl=/usr \
 --with-mhash=${INSTALLDIR} \
 --with-mcrypt=${INSTALLDIR} \
 --with-zlib-dir=${INSTALLDIR} \
 --with-jpeg-dir=/usr \
 --with-png-dir=/usr \
 --with-gd \
 --enable-gd-native-ttf \
 --enable-memory-limit
 --enable-ftp \
 --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"

# ---- end of user-editable bits. Hopefully! ----

# Push the install dir's bin directory into the path
export PATH=${INSTALLDIR}/bin:$PATH

#setup directories
mkdir -p ${SRCDIR}
mkdir -p ${INSTALLDIR}
mkdir -p ${DISTDIR}
cd ${DISTDIR}

# Get all the required packages
wget -c http://us.php.net/distributions/${PHP5}.tar.gz
wget -c http://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz
wget -c http://easynews.dl.sourceforge.net/sourceforge/mcrypt/${LIBMCRYPT}.tar.gz
wget -c ftp://xmlsoft.org/libxml2/${LIBXML2}.tar.gz
wget -c ftp://xmlsoft.org/libxml2/${LIBXSLT}.tar.gz
wget -c http://superb-west.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz
wget -c http://www.zlib.net/${ZLIB}.tar.gz
wget -c http://curl.haxx.se/download/${CURL}.tar.gz
wget -c http://kent.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz
wget -c ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
wget -c ftp://ftp.cac.washington.edu/imap/old/${CCLIENT}.tar.Z

echo ---------- Unpacking downloaded archives. This process may take several minutes! ----------

cd ${SRCDIR}
# Unpack them all
echo Extracting ${PHP5}...
tar xzf ${DISTDIR}/${PHP5}.tar.gz
echo Done.
echo Extracting ${LIBICONV}...
tar xzf ${DISTDIR}/${LIBICONV}.tar.gz
echo Done.
echo Extracting ${LIBMCRYPT}...
tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz
echo Done.
echo Extracting ${LIBXML2}...
tar xzf ${DISTDIR}/${LIBXML2}.tar.gz
echo Done.
echo Extracting ${LIBXSLT}...
tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz
echo Done.
echo Extracting ${MHASH}...
tar xzf ${DISTDIR}/${MHASH}.tar.gz
echo Done.
echo Extracting ${ZLIB}...
tar xzf ${DISTDIR}/${ZLIB}.tar.gz
echo Done.
echo Extracting ${CURL}...
tar xzf ${DISTDIR}/${CURL}.tar.gz
echo Done.
echo Extracting ${LIBIDN}...
tar xzf ${DISTDIR}/${LIBIDN}.tar.gz
echo Done.
echo Extracting ${CCLIENT}...
uncompress -cd ${DISTDIR}/${CCLIENT}.tar.Z |tar x
echo Done.
echo Extracting ${FREETYPE}...
tar xzf ${DISTDIR}/${FREETYPE}.tar.gz
echo Done.

# Build them in the required order to satisfy dependencies.

#libiconv
cd ${SRCDIR}/${LIBICONV}
./configure --enable-extra-encodings --prefix=${INSTALLDIR}
# make clean
make
make install

#libxml2
cd ${SRCDIR}/${LIBXML2}
./configure --with-iconv=${INSTALLDIR} --prefix=${INSTALLDIR}
# make clean
make
make install

#libxslt
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

#zlib
cd ${SRCDIR}/${ZLIB}
./configure --shared --prefix=${INSTALLDIR}
# make clean
make
make install

#libmcrypt
cd ${SRCDIR}/${LIBMCRYPT}
./configure --disable-posix-threads --prefix=${INSTALLDIR}
# make clean
make
make install

#libmcrypt lltdl issue!!
cd  ${SRCDIR}/${LIBMCRYPT}/libltdl
./configure --prefix=${INSTALLDIR} --enable-ltdl-install
# make clean
make
make install

#mhash
cd ${SRCDIR}/${MHASH}
./configure --prefix=${INSTALLDIR}
# make clean
make
make install

#freetype
cd ${SRCDIR}/${FREETYPE}
./configure --prefix=${INSTALLDIR}
# make clean
make
make install

#libidn
cd ${SRCDIR}/${LIBIDN}
./configure --with-iconv-prefix=${INSTALLDIR} --prefix=${INSTALLDIR}
# make clean
make
make install

#cURL
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

# c-client
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

#PHP 5
cd ${SRCDIR}/${PHP5}
./configure ${PHPFEATURES}
# make clean
make
make install

#copy config file
mkdir -p ${INSTALLDIR}/etc/php5/${DOMAIN}
cp ${SRCDIR}/${PHP5}/php.ini-dist ${INSTALLDIR}/etc/php5/${DOMAIN}/php.ini

#copy PHP CGI
mkdir -p ${HOME}/${DOMAIN}/cgi-bin
chmod 0755 ${HOME}/${DOMAIN}/cgi-bin
cp ${INSTALLDIR}/bin/php ${HOME}/${DOMAIN}/cgi-bin/php.cgi
rm -rf $SRCDIR $DISTDIR
echo ---------- INSTALL COMPLETE! ----------

Alternative PHP 5 install scripts

These are alternative PHP 5 install scripts created by Charles Wiltgen, who created them to work around problems he was having with the "main" PHP 5 install script.

First, run php5-install-prep.sh to download and unpack all prerequisite packages.

Then, run php5-install.sh to compile and install PHP 5 and all prerequisites.

php5-install-prep.sh

#!/bin/sh

# Version 0.5, 2007-01-15
#
# - Updated 2007-01-15 by Charles Wiltgen (charles@wiltgen.net)
#   - Make "nicer" to help keep it from getting killed by DreamHost
#   - Make less verbose to keep signal-to-noise level high
# - Updated 2006-12-25 by Carl McDade (hiveminds.co.uk)
#   - Allow memory limit and freetype

echo php5-install-prep.sh
echo - This script downloads and unpacks all prerequisite packages
echo - Run this script before php5-install.sh
echo
read -p  "(Press any key to continue)" temp;
echo

# Abort on any errors
set -e

# The domain in which to install the PHP CGI script.
export DOMAIN="your-domain-here.com"

# Where do you want all this stuff built? I'd recommend picking a local
# filesystem.
# ***Don't pick a directory that already exists!***  We clean up after
# ourselves at the end!
SRCDIR=${HOME}/source

# And where should it be installed?
INSTALLDIR=${HOME}/php5

# Set DISTDIR to somewhere persistent, if you plan to muck around with this
# script and run it several times!
DISTDIR=${HOME}/dist

# Update version information here.
PHP5="php-5.2.0"
LIBICONV="libiconv-1.11"
LIBMCRYPT="libmcrypt-2.5.7"
LIBXML2="libxml2-2.6.27"
LIBXSLT="libxslt-1.1.18"
MHASH="mhash-0.9.7.1"
ZLIB="zlib-1.2.3"
CURL="curl-7.14.0"
LIBIDN="libidn-0.6.8"
CCLIENT="imap-2004g"
CCLIENT_DIR="imap-2004g" # Another pest!
FREETYPE="freetype-2.2.1"

echo
echo --- Cleaning up any previous attempts
echo

# Pre-prep cleanup
rm -rf $SRCDIR $DISTDIR

# Push the install dir's bin directory into the path
export PATH=${INSTALLDIR}/bin:$PATH

#setup directories
mkdir -p ${SRCDIR}
mkdir -p ${INSTALLDIR}
mkdir -p ${DISTDIR}
cd ${DISTDIR}

# Get all the required packages
echo
echo --- Downloading all required packages ---
echo

wget -c http://us.php.net/distributions/${PHP5}.tar.gz
wget -c http://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz
wget -c http://umn.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.7.tar.gz
wget -c ftp://xmlsoft.org/libxml2/${LIBXML2}.tar.gz
wget -c ftp://xmlsoft.org/libxml2/${LIBXSLT}.tar.gz
wget -c http://umn.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz
wget -c http://www.zlib.net/${ZLIB}.tar.gz
wget -c http://curl.haxx.se/download/${CURL}.tar.gz
wget -c http://umn.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz
wget -c ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
wget -c ftp://ftp.cac.washington.edu/imap/old/${CCLIENT}.tar.Z

echo
echo --- Unpacking downloaded archives. This process may take several minutes! ---
echo

cd ${SRCDIR}
# Unpack them all
echo Extracting ${PHP5}...
tar xzf ${DISTDIR}/${PHP5}.tar.gz > /dev/null
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}...
tar xzf ${DISTDIR}/${ZLIB}.tar.gz > /dev/null
echo Done.
echo Extracting ${CURL}...
tar xzf ${DISTDIR}/${CURL}.tar.gz > /dev/null
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.
echo Extracting ${FREETYPE}...
tar xzf ${DISTDIR}/${FREETYPE}.tar.gz > /dev/null
echo Done.

echo --------------------------------------------------
echo -- Done downloading and unpacking prerequisites --
echo --------------------------------------------------

php5-install.sh

#!/bin/sh

echo php5-install.sh
echo - This script compiles and installs PHP 5 and all prerequisites
echo - Run php5-install-prep.sh before running this script
echo
read -p  "(Press any key to continue)" temp;
echo

# Version 0.5, 2007-01-15
#
# - Updated 2007-01-15 by Charles Wiltgen (charles@wiltgen.net)
#   - Make "nicer" to help keep it from getting killed by DreamHost
#   - Make less verbose to keep signal-to-noise level high
# - Updated 2006-12-25 by Carl McDade (hiveminds.co.uk)
#   - Allow memory limit and freetype

# Abort on any errors
set -e

##################################
# User-editable settings (start) #
##################################

# The domain in which to install the PHP CGI script
export DOMAIN="your-domain-here.com"

# Where do you want all this stuff built? I'd recommend picking a local
# filesystem.
# ***Don't pick a directory that already exists!***  We clean up after
# ourselves at the end!
SRCDIR=${HOME}/source

# And where should it be installed?
INSTALLDIR=${HOME}/php5

# Set DISTDIR to somewhere persistent, if you plan to muck around with this
# script and run it several times!
DISTDIR=${HOME}/dist

# Update version information here.
PHP5="php-5.2.0"
LIBICONV="libiconv-1.11"
LIBMCRYPT="libmcrypt-2.5.7"
LIBXML2="libxml2-2.6.27"
LIBXSLT="libxslt-1.1.18"
MHASH="mhash-0.9.7.1"
ZLIB="zlib-1.2.3"
CURL="curl-7.14.0"
LIBIDN="libidn-0.6.8"
CCLIENT="imap-2004g"
CCLIENT_DIR="imap-2004g" # Another pest!
FREETYPE="freetype-2.2.1"

# What PHP features do you want enabled?
PHPFEATURES="--prefix=${INSTALLDIR} \
	--with-config-file-path=${INSTALLDIR}/etc/php5/${DOMAIN} \
	--enable-fastcgi \
	--enable-force-cgi-redirect \
	--with-xml \
	--with-libxml-dir=${INSTALLDIR} \
	--with-freetype-dir=${INSTALLDIR} \
	--enable-soap \
	--with-openssl=/usr \
	--with-mhash=${INSTALLDIR} \
	--with-mcrypt=${INSTALLDIR} \
	--with-zlib-dir=${INSTALLDIR} \
	--with-jpeg-dir=/usr \
	--with-png-dir=/usr \
	--with-gd \
	--enable-gd-native-ttf \
	--enable-memory-limit
	--enable-ftp \
	--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"

################################
# User-editable settings (end) #
################################

echo ------------------------------------------------------
echo -- Compiling and installing PHP 5 and prerequisites --
echo ------------------------------------------------------

# Pre-prep cleanup
rm -rf $INSTALLDIR

# Build packages in the required order to satisfy dependencies.

#
# libiconv
#

echo
echo --- Building libiconv
echo
cd ${SRCDIR}/${LIBICONV}
echo "    Configuring..."
./configure --enable-extra-encodings --prefix=${INSTALLDIR} \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Done!"

#
# libxml2
#

echo
echo --- Building libxml2
echo
cd ${SRCDIR}/${LIBXML2}
echo "    Configuring..."
./configure --with-iconv=${INSTALLDIR} --prefix=${INSTALLDIR} \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Done!"

#
# libxslt
#

echo
echo --- Building libxslt
echo
cd ${SRCDIR}/${LIBXSLT}
echo "    Configuring..."
./configure --prefix=${INSTALLDIR} \
	--with-libxml-prefix=${INSTALLDIR} \
	--with-libxml-include-prefix=${INSTALLDIR}/include/ \
	--with-libxml-libs-prefix=${INSTALLDIR}/lib/ \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Done!"

#
# zlib
#

echo
echo --- Building: zlib
echo
cd ${SRCDIR}/${ZLIB}
echo     Configuring...
./configure --shared --prefix=${INSTALLDIR} \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Done!"

#
# libmcrypt
#

echo
echo --- Building: libmcrypt
echo
cd ${SRCDIR}/${LIBMCRYPT}
echo "    Configuring..."
./configure --disable-posix-threads --prefix=${INSTALLDIR} \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Done!"

#libmcrypt lltdl issue!!
cd  ${SRCDIR}/${LIBMCRYPT}/libltdl
echo "    Configuring..."
./configure --prefix=${INSTALLDIR} --enable-ltdl-install \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Done!"

#
# mhash
#

echo
echo --- Building: mhash
echo
cd ${SRCDIR}/${MHASH}
echo "    Configuring..."
./configure --prefix=${INSTALLDIR} \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Done!"

#
# freetype
#

echo
echo --- Building: freetype
echo
cd ${SRCDIR}/${FREETYPE}
echo "    Configuring..."
./configure --prefix=${INSTALLDIR} \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Done!"

#
# libidn
#

echo
echo --- Building: libidn
echo
cd ${SRCDIR}/${LIBIDN}
echo "    Configuring..."
./configure --with-iconv-prefix=${INSTALLDIR} --prefix=${INSTALLDIR} \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Done!"

#
# cURL
#

echo
echo --- Building: cURL
echo
cd ${SRCDIR}/${CURL}
echo "    Configuring..."
./configure --with-ssl=${INSTALLDIR} --with-zlib=${INSTALLDIR} \
	--with-libidn=${INSTALLDIR} --enable-ipv6 --enable-cookies \
	--enable-crypto-auth --prefix=${INSTALLDIR} \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Done!"

#
# c-client
#

echo
echo --- Building: c-client
echo
cd ${SRCDIR}/${CCLIENT_DIR}
echo "    Making..."
make ldb  > /dev/null 2>&1
echo "    Installing..."
cp c-client/c-client.a ${INSTALLDIR}/lib/libc-client.a
cp c-client/*.h ${INSTALLDIR}/include
echo "    Done!"

#
# PHP 5
#

echo
echo --- Building PHP 5 ---
echo
cd ${SRCDIR}/${PHP5}
echo "    Configuring..."
./configure ${PHPFEATURES} \
	> /dev/null 2>&1
echo "    Making..."
nice -n 19 make > /dev/null 2>&1
echo "    Installing..."
make install > /dev/null 2>&1
echo "    Copying configuration file (PHP.INI)"
mkdir -p ${INSTALLDIR}/etc/php5/${DOMAIN}
cp ${SRCDIR}/${PHP5}/php.ini-dist ${INSTALLDIR}/etc/php5/${DOMAIN}/php.ini
echo "    Copying PHP CGI"
mkdir -p ${HOME}/${DOMAIN}/cgi-bin
chmod 0755 ${HOME}/${DOMAIN}/cgi-bin
cp ${INSTALLDIR}/bin/php ${HOME}/${DOMAIN}/cgi-bin/php.cgi

echo
echo --- Cleaning up
echo

rm -rf $SRCDIR $DISTDIR

echo ---------------------------------------
echo ---------- INSTALL COMPLETE! ----------
echo ---------------------------------------

# Finally, you need to add this to your site's .htaccess file to use
# the version of PHP that you've just compiled:
#
# AddHandler phpFive .php
# Action phpFive /cgi-bin/php.cgi