Installation of customized PHP
Posted by: viktorkh
Posted on: 2007-02-08 11:51:00
Hello!
I need the enable-register_globals and enable-safe_mode. I wrote it in php.ini - but it didn't work. I got Off for this features. Some features is working (like allow_url_fopen - On).
This is the code of installation - what is wrong there:
#!/bin/bash
# Abort on any errors
set -e
# The domain in which to install the PHP CGI script.
export DOMAIN="..."
# Update version information here.
PHP="php-4.4.4"
LIBICONV="libiconv-1.10"
LIBMCRYPT="libmcrypt-2.5.7"
LIBXML2="libxml2-2.6.27"
LIBXSLT="libxslt-1.1.18"
MHASH="mhash-0.9.4"; MHASH_TAR="${MHASH}a" # Pests!
ZLIB="zlib-1.2.3"
CURL="curl-7.15.2"
LIBIDN="libidn-0.6.2"
FREETYPE="freetype-2.1.10"
IMAP="imap-2004g"
# Set DISTDIR to somewhere persistent if you plan to muck around with this
# script and run it several times! It is where distributions are downloaded.
DISTDIR=${HOME}/dist
# Where do you want all this stuff built? Using a local filesystem is best.
# ***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? A versioned directory eases upgrades!
INSTALLDIR=${HOME}/${PHP}
# A simple name link eases use
ln -s ${INSTALLDIR} php
# What PHP features do you want enabled?
PHPFEATURES="--prefix=${INSTALLDIR}
--with-config-file-path=${INSTALLDIR}/etc/php4
--enable-force-cgi-redirect
--with-xml --with-libxml-dir=${INSTALLDIR}
--with-freetype-dir=${INSTALLDIR}
--enable-soap
--with-xsl=${INSTALLDIR}
--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-ftp
--enable-sockets
--enable-wddx
--with-iconv=${INSTALLDIR}
--enable-calendar
--with-curl=${INSTALLDIR}
--enable-mbstring
--enable-mbregex
--enable-allow_url_fopen
--enable-allow_call_time_pass_reference
--enable-display_errors
--enable-enable_dl
--enable-expose_php
--enable-file_uploads
--enable-html_errors
--enable-magic_quotes_gpc
--enable-register_argc_argv
--enable-report_memleaks
--enable-short_open_tag
--enable-register_globals
--enable-safe_mode
--with-mysql=/usr --with-mysqli
--with-imap=${INSTALLDIR}"
# ---- 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://us3.php.net/distributions/${PHP}.tar.gz
wget -c http://ftp.gnu.org/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://easynews.dl.sourceforge.net/sourceforge/mhash/${MHASH_TAR}.tar.gz
wget -c http://www.zlib.net/${ZLIB}.tar.gz
wget -c http://curl.haxx.se/download/${CURL}.tar.gz
wget -c ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
wget -c http://easynews.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz
wget -c ftp://ftp.cac.washington.edu/imap/old/${IMAP}.tar.Z
cd ${SRCDIR}
# Unpack them all
tar xzf ${DISTDIR}/${PHP}.tar.gz
tar xzf ${DISTDIR}/${LIBICONV}.tar.gz
tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz
tar xzf ${DISTDIR}/${LIBXML2}.tar.gz
tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz
tar xzf ${DISTDIR}/${MHASH_TAR}.tar.gz
tar xzf ${DISTDIR}/${ZLIB}.tar.gz
tar xzf ${DISTDIR}/${CURL}.tar.gz
tar xzf ${DISTDIR}/${LIBIDN}.tar.gz
tar xzf ${DISTDIR}/${FREETYPE}.tar.gz
uncompress -cd ${DISTDIR}/${IMAP}.tar.Z |tar x
# Build them in the required order to satisfy dependencies.
#libiconv
cd ${SRCDIR}/${LIBICONV}
./configure --enable-extra-encodings --prefix=${INSTALLDIR}
make
make install
#libxml2
cd ${SRCDIR}/${LIBXML2}
./configure --with-iconv=${INSTALLDIR} --prefix=${INSTALLDIR}
make
make install
#libxslt
cd ${SRCDIR}/${LIBXSLT}
./configure --with-libxml-prefix=${INSTALLDIR} --prefix=${INSTALLDIR}
make
make install
#zlib
cd ${SRCDIR}/${ZLIB}
./configure --shared --prefix=${INSTALLDIR}
make
make install
#libmcrypt
cd ${SRCDIR}/${LIBMCRYPT}
./configure --disable-posix-threads --prefix=${INSTALLDIR}
make
make install
#mhash
cd ${SRCDIR}/${MHASH}
./configure --prefix=${INSTALLDIR}
make
make install
# FIXME: For some reason, mincludes.h isn't copied across
cp ${SRCDIR}/${MHASH}/include/mutils/mincludes.h ${INSTALLDIR}/include/mutils
#libidn
cd ${SRCDIR}/${LIBIDN}
./configure --with-iconv-prefix=${INSTALLDIR} --prefix=${INSTALLDIR}
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
make install
#freetype
cd ${SRCDIR}/${FREETYPE}
./configure --prefix=${INSTALLDIR}
make
make install
# imap
cd ${SRCDIR}/${IMAP}
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 4
cd ${SRCDIR}/${PHP}
./configure ${PHPFEATURES}
make
make install
#copy config file
mkdir -p ${INSTALLDIR}/etc/php4
cp ${SRCDIR}/${PHP}/php.ini-dist ${INSTALLDIR}/etc/php4/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
echo ---------- INSTALL COMPLETE! ----------