One of out clients needs a PHP4 stack to run legacy web applications. We use Debian and we do not want to replace Squeeze’s PHP5, as many other Debian-packaged applications like squirrelmail or PhpMyAdmin need it. Our solution is to run PHP4 through fcgid.


In order to install php4-cgi we choose to add the amazing debian snapshots archive to apt sources.list. This gives us access to old Debian packages (there are other methods).

cat /etc/apt/sources.list.d/etch.list
# installed from
deb lenny main

install php4 normally

apt-get update
apt-get install php4-cgi php4-cli php4-common php4-curl php4-dev php4-domxml php4-gd php4-imap php4-mcal php4-mcrypt php4-mysql

to configure an Apache VirtualHost to use PHP4 instead of PHP5 add this configuration:

<VirtualHost ...>

  # PHP4
  <FilesMatch "\.ph(p3?|tml)$">
    Options ExecCGI FollowSymLinks
    SetHandler fcgid-script
    FCGIWrapper /usr/bin/php-cgi .php