2

I need to have both installed and running on the same server instance for a dev environment.

They both need to handle the .php extension, I have read that this can be done by .htaccess set up but have know idea how to do the actual installation.

Google/Serverfault searches came up dry. Any information/resource links would be useful. Or if it has been asked as I am sure it would be rather common, please redirect me to the dupe.

0

1 Answer 1

3

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.

3
  • I need to handle the .php extension, renaming is not an option for this legacy behemoth. Could you explain why there is a hit to performance with using that option? cgi mode? or is there something about the directive in .htaccess?
    – stuckinphp
    Nov 17, 2009 at 4:01
  • .htaccess is ok :) It's a drawback in the very principle of CGI: every time a page is opened Apache launches the cgi executable and handles php script with it. Launching a process every time is much slower than having a built-in module. That's why FCGI was created: it launches cgi scripts and handles all scripts with several processes that, once launched, don't stop :) You can try CGI: it's rather slow, but still acceptable in some cases.
    – kolypto
    Nov 17, 2009 at 8:58
  • Suggestion updated. It will allow you to run PHP4 & PHP5 simultaneously without using CGI or renaming files :)
    – kolypto
    Nov 17, 2009 at 9:25

You must log in to answer this question.