PHP 4 & 5 Together

I would like to see support added for PHP 5 as an addition to PHP 4.3.x series. I would like to test some of my coding in a live enviorment, but keep putting it off. I suppose I really should compile my own PHP 5 CGI - but that is going to take much more time and effort. And I think a lot of people in the hosting business might benefit from being able to offer BOTH on a hosting package. Thanks.

The only problem is compatibility. If php scripts had a .php4 extension and php5 scripts .php5 it’d be easier. As it is Apache will only process a single extension for .php, which defaults to whatever PHP version is installed.

A PHP CGI would partially solve the problem and this wouldn’t be terrible to get going but would require a lot of explanation to end-users wishing to use it.


I think it has become a standard practice amongst many of PHP4 + PHP5 providers to tell customers to use the extension PHP5. That should be alright to that point I believe. IT might be possible to use .htaccess to override this option in the virtual host I believe.

Instead of CGI - FastCGI binary might be a great idea. It would allow for OPCode caching.

I’ve tested an install of both php4 and php5 on the same server.

Both loaded as module. Not php4 as module and php5 running as cgi or using two Apache instances.

I didn’t run php5 as cgi for security reason.

php4 with : AddType application/x-httpd-php .php .php3 .php4
php5 with : AddType application/x-httpd-php .php5

and same idea for loading the modules.

But when I create a file test.php and test.php5 both with phpinfo() some times I have php4 as version and some times php5.

It seems there really is share module pbm or whatever (php5 is not installed in the same php4 directory)

So it seems that the only available solution is to have php5 running as CGI or to create two differents Apache instance, one for php4 and one for php5.

Grrrr… I don’t like any of these two solutions (security, interworx compliance, performance).

Maybe there is an other solution ?