Apache with multiple PHP installations on Debian
This little how to explains how to install more than 1 PHP installation on a Debian Linux system.

First it is assumed, that Apache, PHP, MySQL are already installed on the system and running. Using the standard debian packages, PHP will be installed with the regular Apache handler. We're gonna install an additional installation of PHP (from source) using the cgi handler. On my system, I had PHP 5.2.x installed already and as a second option I installed PHP 5.3.6.

Install PHP 5.3.6 from source

Here is how to install PHP 5.3.6 to the directory /usr/local/php/5.3.6:
cd /opt
wget http://ch.php.net/get/php-5.3.6.tar.gz/from/this/mirror
tar -xzf php-5.3.6.tar.gz
cd php-5.3.6

apt-get install libmysqlclient15-dev

Don't use --with-apxs or --with-apxs2 options

rm config.cache;make clean;./configure -prefix=/usr/local/php/5.3.6 --with-libxml-dir=/usr/ -with-zlib-dir=/usr/ --with-mysql=/usr/ --with-mysqli --with-png-dir=/usr/ --with-jpeg-dir=/usr/ --with-curl -enable-soap -enable-sockets -enable-mbstring --with-gd --with-freetype-dir

make install

cd /usr/local/php/5.3.6/lib
#ln -s /etc/php5/apache2/php.ini php.ini

cp /etc/php5/apache2/php.ini ./

From the php.ini used in 5.2.x, I had to change the following options:

safe_mode = Off
;register_long_arrays = On
;magic_quotes_gpc = On
date.timezone = 'Europe/Berlin'

Execute /usr/local/php/5.3.6/bin/php to see if there are errors, and correct them in php.ini.

Enable Apache2 actions module:
a2enmod actions

If your html files are in /home/www (confixx default) and /usr/lib/apache2/suexec -V reports AP_DOC_ROOT="/var/www", fix this problem with the following commands:
mv /var/www /var/www_old
ln -s /home/www /var/www

Enable PHP 5.3.6 for one website

Install to one websites cgi-bin directory:
cp /usr/local/php/5.3.6/bin/php-cgi /home/www/path/to/html/cgi-bin/php536

Fix owner / permission:
chmod 755 /home/www/path/to/html/cgi-bin/php536
chown web7:web7 /home/www/path/to/html/cgi-bin/php536

Change in httpd.conf to load new php version for any directory you want:

<Directory "/home/www/web7/html/joomla">
 AddHandler php536-script .php
 Action php536-script /cgi-bin/php536

For errors check the following log files:

- http://www.tutorials.de/webserver-tutorials/219595-apache-mit-verschiedenen-php-versionen.html
- http://hurring.com/scott/howto/php4_and_php5/
admin / Dec 05, 2010
2004 - 2023 / lookass.ch