Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 29th March 2011, 14:01
Croydon Croydon is offline
ISPConfig Developer
 
Join Date: Jul 2007
Location: Koblenz, Germany
Posts: 922
Thanks: 16
Thanked 259 Times in 206 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:
http://www.soeren-hentzschel.at/tech..._phpmod_fcgid/

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. deb_php52.sh) and run it.
After the script completes you will get a /root/fcgi-copy.sh file that you have to run once for each web you will enable PHP 5.2 for.
Code:
#!/bin/sh

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

DEBIAN_OK=`cat /etc/debian_version`

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

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 ;
fi

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 "http://de.php.net/get/php-5.2.17.tar.bz2/from/this/mirror" -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 ;
  else
    sed -i -e "s/^\(\s*FcgidConnectTimeout.*\)$/\1\n  FcgidMaxRequestLen 1073741824/" /etc/apache2/mods-available/fcgid.conf ;
  fi
else
  sed -i -r "s/^\s*FcgidMaxRequestLen\s+\d+.*$/FcgidMaxRequestLen 1073741824/" /etc/apache2/mods-available/fcgid.conf ;
fi

/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 ;
else
  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 ;
fi

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/"
    
exec $FCGID_STARTER_PHPBIN
' > /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
WEB_USER=$1
WEB_ID=$2
 
if [ "$WEB_USER" = "" ] ; then
echo "$0 <WEB_USER> <WEB_ID>.";
echo "z. B. $0 web4_ftp_adm web4";
exit 1;
fi
 
if [ "$WEB_ID" = "" ] ; then
echo "$0 <WEB_USER> <WEB_ID>.";
echo "z. B. $0 web4_ftp_adm web4";
exit 1;
fi
 
if [ ! -e "/var/www/${WEB_ID}" ] ; then
echo "Directory /var/www/${WEB_ID} is missing."
exit 1;
fi
 
if [ ! -e "/etc/php52/php-fcgi" ] ; then
echo "Template directory /etc/php52/php-fcgi is missing."
exit 1;
fi
 
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/fcgi-copy.sh

chmod 700 /root/fcgi-copy.sh

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

Last edited by Croydon; 10th May 2011 at 11:06.
Reply With Quote
The Following 4 Users Say Thank You to Croydon For This Useful Post:
counterpoint (6th September 2011), falko (30th March 2011), Qluripax (22nd August 2011), till (29th March 2011)
Sponsored Links
  #2  
Old 22nd August 2011, 15:45
Qluripax Qluripax is offline
HowtoForge Supporter
 
Join Date: Dec 2009
Posts: 8
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Thanks for an interesting post. A question to those guys ho know more about ISPconfig: Is this post implementable on a Debian 6 with ISPconfig 3?
Reply With Quote
  #3  
Old 22nd August 2011, 17:17
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,488
Thanks: 813
Thanked 5,260 Times in 4,124 Posts
Default

ISPConfig 3 has fastcgi support out of the box, so there is no need for such a hack in. Just install your ispconfig 3 server as described in the perfect setup guide and you will get fastcgi support.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #4  
Old 6th September 2011, 16:35
counterpoint counterpoint is offline
Junior Member
 
Join Date: Jan 2010
Posts: 21
Thanks: 1
Thanked 5 Times in 5 Posts
 
Default

Thanks very much for this helpful script. I ran into a few small issues along the way, and also found it useful to adapt the final result to suit How To Set Up Apache2 With mod_fcgid And PHP5 On Debian Lenny (which also works fine for Squeeze). I already have a script for creating new sites in that environment.

First I found the script wouldn't run, because the target system still had the Squeeze default of the dash shell. That can be changed to defaulting to bash by running:
Code:
dpkg-reconfigure dash
and choosing the "no" option. Alternatively, change the shebang on the first line to specifically select bash:
Code:
#!/bin/bash
Then the system did not return anything with 64 in it from uname, so the selection of 32 bit or 64 bit compile was going wrong. For that I simply hacked the script to:
Code:
# Override choice of 64 bit
CHECK="1"
#CHECK=`uname -a | grep 'amd64'`
to choose 64 bit.

It also transpired that make was not installed in the target system. That can be checked by:
Code:
aptitude search make
and if necessary installed with
Code:
aptitude install make
If the result is to be used in conjunction with a system created using the "how to" mentioned above, then individual web sites can be set up exactly as in the "how to" except that the php-fcgi-starter file is changed to:
Code:
#!/bin/sh
PHPRC=/etc/php52/cgi/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec /usr/bin/php52/php-cgi
(although I actually use different values for the configuration parameters)
Reply With Quote
The Following User Says Thank You to counterpoint For This Useful Post:
falko (7th September 2011)
Reply

Bookmarks

Tags
debian, ispconfig 2, php 5.2, squeeze

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
coexistence of php4 and php5 on ISPC3 AceLine Tips/Tricks/Mods 5 5th November 2010 14:56
libWand.so.10 error Taxick Installation/Configuration 8 3rd May 2009 01:27
ISPConfig virtual web pages not working mike_phi Installation/Configuration 8 7th May 2008 16:51
php script injections Grizzly General 21 18th July 2006 08:55
e-mail problem!!! Debian 3.1 maroonworks Installation/Configuration 18 6th December 2005 14:42


All times are GMT +2. The time now is 07:59.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.