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."
Recent comments
14 hours 19 min ago
21 hours 38 sec ago
1 day 51 min ago
1 day 2 hours ago
1 day 10 hours ago
1 day 20 hours ago
1 day 21 hours ago
2 days 46 min ago
2 days 5 hours ago
2 days 5 hours ago