View Single Post
Old 29th March 2011, 15:01
Croydon Croydon is offline
ISPConfig Developer
Join Date: Jul 2007
Location: Koblenz, Germany
Posts: 932
Thanks: 16
Thanked 264 Times in 208 Posts
Post ISPConfig on Debian 6 with optional PHP 5.2 for single webs

Updating a running debian 5 (lenny) server with client webs on it to debian 6 (squeeze) can lead to problems if some of the webs rely on functions that are deprecated or behave different in debian 6.

I just puglished a blog article in german language here:

It shows how to add php 5.2.17 support to debian 6 with mod_fcgid using apache directives in ISPConfig 2.

Here is the complete shell script that does all the needed steps automatically.
(my original script is in german, so i translated the neccessary parts)

The script does:
- install neccessary packages via apt
- configure mod_fcgid in apache2
- create skeleton fcgi-starter dir
- create script to prepare webs
- download, compile and install php 5.2.17 (32 or 64 bit)

I cannot guarantee this will work for you as it does for me. Use it at your own risk!
Copy the content of the following code section to a shell file (e.g. and run it.
After the script completes you will get a /root/ file that you have to run once for each web you will enable PHP 5.2 for.

if [[ $(id -u) -ne 0 ]] ; then
    echo "Please run this script with root privilegues!" ;
    exit 2 ;

DEBIAN_OK=`cat /etc/debian_version`

if [[ "$DEBIAN_OK" = "" ]] ; then
  echo "This is not a debian server?!...";

read -p "We are going to install some debian packages now! Do you want to proceed (y/N)? " DOIT

if [[ "$DOIT" != "y" ]] ; then
    echo "Abgebrochen." ;
    exit 0 ;

apt-get install -q -y libapache2-mod-fcgid apache2-suexec libpcre3-dev libpcre++-dev libpng12-dev libbz2-dev libcurl4-openssl-dev libc-client2007e-dev libjpeg-dev libgif-dev libgif4 libpthread-stubs0 libpthread-stubs0-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxpm-dev x11proto-core-dev x11proto-input-dev x11proto-kb-dev xtrans-dev libfreetype6-dev libxml2-dev

a2enmod fcgid
a2enmod suexec

cd /tmp
wget -q "" -O php.tar.bz2
tar xjf php.tar.bz2
cd php-5.2.17

CHECK=`grep "FcgidMaxRequestLen" /etc/apache2/mods-available/fcgid.conf`
if [[ "$CHECK" = "" ]] ; then
  CHECK=`grep "FcgidConnectTimeout" /etc/apache2/mods-available/fcgid.conf`
  if [[ "$CHECK" = "" ]] ; then
    echo "FcgidMaxRequestLen 1073741824" >> /etc/apache2/mods-available/fcgid.conf ;
    sed -i -e "s/^\(\s*FcgidConnectTimeout.*\)$/\1\n  FcgidMaxRequestLen 1073741824/" /etc/apache2/mods-available/fcgid.conf ;
  sed -i -r "s/^\s*FcgidMaxRequestLen\s+\d+.*$/FcgidMaxRequestLen 1073741824/" /etc/apache2/mods-available/fcgid.conf ;

/etc/init.d/apache2 stop
/etc/init.d/apache2 start

CHECK=`uname -a | grep 'amd64'`
if [[ "$CHECK" = "" ]] ; then
  echo "Compiling on 32Bit system" ;
  ./configure --prefix=/usr/share/php52 --datadir=/usr/share/php52 --mandir=/usr/share/man --bindir=/usr/bin/php52 --with-libdir=lib --includedir=/usr/include --sysconfdir=/etc/php52/apache2 --with-config-file-path=/etc/php52/apache2 --with-config-file-scan-dir=/etc/php52/conf.d --enable-libxml --enable-session --with-pcre-regex=/usr --enable-xml --enable-simplexml --enable-filter --disable-debug --enable-inline-optimization --disable-rpath --disable-static --enable-shared --with-pic --with-gnu-ld --with-mysql --with-gd --with-jpeg-dir --with-png-dir --with-xpm-dir --enable-exif --enable-fastcgi --enable-force-cgi-redirect --with-zlib --with-bz2 --with-curl --with-ldap --with-mysqli --with-ttf --with-freetype-dir --enable-soap --enable-sockets --enable-calendar --enable-ftp --enable-mbstring --enable-gd-native-ttf --enable-bcmath --enable-zip --with-pear --with-openssl --with-imap --with-imap-ssl --with-kerberos ;
  echo "Compiling on 64Bit system" ;
  ./configure --prefix=/usr/share/php52 --datadir=/usr/share/php52 --mandir=/usr/share/man --bindir=/usr/bin/php52 --with-libdir=lib64 --includedir=/usr/include --sysconfdir=/etc/php52/apache2 --with-config-file-path=/etc/php52/apache2 --with-config-file-scan-dir=/etc/php52/conf.d --enable-libxml --enable-session --with-pcre-regex=/usr --enable-xml --enable-simplexml --enable-filter --disable-debug --enable-inline-optimization --disable-rpath --disable-static --enable-shared --with-pic --with-gnu-ld --with-mysql --with-gd --with-jpeg-dir --with-png-dir --with-xpm-dir --enable-exif --enable-fastcgi --enable-force-cgi-redirect --with-zlib --with-bz2 --with-curl --with-ldap --with-mysqli --with-ttf --with-freetype-dir --enable-soap --enable-sockets --enable-calendar --enable-ftp --enable-mbstring --enable-gd-native-ttf --enable-bcmath --enable-zip --with-pear --with-openssl --with-imap --with-imap-ssl --with-kerberos ;

make && make install

echo "Compiled and installed PHP. If errors occured here, please press CTRL-C to abort!"
read -p "Creating scripts now... press ENTER to proceed (CTRL+C to cancel)"

cp /etc/php5/apache2/php.ini /etc/php52/apache2/
mkdir /etc/php52/cgi
cp /etc/php5/apache2/php.ini /etc/php52/cgi/

mkdir -p /etc/php52/php-fcgi/

echo '#!/bin/sh

FCGID_STARTER_PHPBIN="/usr/bin/php52/php-cgi -c /etc/php52/cgi/"
' > /etc/php52/php-fcgi/php-starter

chmod 750 /etc/php52/php-fcgi/php-starter
chattr +i /etc/php52/php-fcgi/php-starter

echo '#!/bin/sh
if [ "$WEB_USER" = "" ] ; then
echo "$0 <WEB_USER> <WEB_ID>.";
echo "z. B. $0 web4_ftp_adm web4";
exit 1;
if [ "$WEB_ID" = "" ] ; then
echo "$0 <WEB_USER> <WEB_ID>.";
echo "z. B. $0 web4_ftp_adm web4";
exit 1;
if [ ! -e "/var/www/${WEB_ID}" ] ; then
echo "Directory /var/www/${WEB_ID} is missing."
exit 1;
if [ ! -e "/etc/php52/php-fcgi" ] ; then
echo "Template directory /etc/php52/php-fcgi is missing."
exit 1;
cp -a /etc/php52/php-fcgi /var/www/${WEB_ID}/
chown -R ${WEB_USER}:${WEB_ID} /var/www/${WEB_ID}/php-fcgi
chattr +i /var/www/${WEB_ID}/php-fcgi/php-starter
find /var/www/${WEB_ID}/web -user www-data -exec chown ${WEB_USER}:${WEB_ID} {} \;
echo "Please copy the following code section to the apache directives of ${WEB_ID}:"
echo "====================================="
echo "SuexecUserGroup ${WEB_USER} ${WEB_ID}"
echo "<FilesMatch \.php$>"
echo "    SetHandler fcgid-script"
echo "</FilesMatch>"
echo ""
echo "AddHandler fcgid-script .php .php4 .php5"
echo "FCGIWrapper \"/var/www/${WEB_ID}/php-fcgi/php-starter\" .php"
echo "FCGIWrapper \"/var/www/${WEB_ID}/php-fcgi/php-starter\" .php5"
echo "FCGIWrapper \"/var/www/${WEB_ID}/php-fcgi/php-starter\" .php4"
echo ""
echo "====================================="' > /root/

chmod 700 /root/

echo "ALL DONE!"
echo "Run the command /root/ to prepare a web for PHP 5.2.17."

Last edited by Croydon; 10th May 2011 at 12:06.
Reply With Quote
Sponsored Links