Running php4 and php5 along side each other

You can do it by building two apache modules with different types: "application/x-httpd-php4" and "application/x-httpd-php5". Load them both into apache, and specify in httpf.conf:

    AddType application/x-httpd-php4 .php4
    AddType application/x-httpd-php5 .php5
    AddType application/x-httpd-php5 .php # the default

Now you'll have to use ".php4" extension for files to be handled with PHP4, and ".php5" for PHP5. ".php" files are also processes with PHP5 by default.

UPD: In order to have some folders executing PHP scripts with PHP4 module you can override the default PHP5 with PHP4. Just use this in .htaccess:

AddType application/x-httpd-php4 .php

With php in CGI mode you'll be able to use .htaccess configuration. Build both PHP versions in CGI mode, place the executables into cgi-bin folder, and try the following in .htaccess:

AddType application/cgi-php php
Action application/cgi-php /cgi-bin/php4.cgi

However, this way is much worse in the means of performance.