I want to configure a local apache server to serve php files with different php versions. In my document root I have phpinfo.php
, now if I go to http://localhost/phpinfo.php4
, I want to see the phpinfo.php file processed with php4, if I go to http://localhost/phpinfo.php5
I want to see the same file processed with php5.
Note: both php 4 and 5 are already installed side by side, I have no problem configuring apache to treat files that have a .php4
or .php5
extension on the filesystem with the correct php version. What I want is for apache to do the following:
- If the url-path ends in
.php5
, serve the file which has a.php
extension on the filesystem using theapplication/x-httpd-php5
handler. - If the url-path ends in
.php4
, serve the same file with the.php
extension on the filesystem using theapplication/x-httpd-php4
handler.
After a bit of trial & error I figured it out. The magic incantations are
where
application/x-httpd-php
is the default handler that mod_php5 registers, andphp4
is a custom cgi handler that calls php4. The part I had most trouble figuring out is thePT
(passthrough) flag, which is necessary for cgi handlers to work. PT causes other modules that do url rewriting to also do their job, and mod_cgi is such a module.