Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Will you register a new account for your next question? :))) –  kolypto Nov 18 '09 at 0:47
add comment

1 Answer

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.

share|improve this answer
    
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 '09 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 '09 at 8:58
    
Suggestion updated. It will allow you to run PHP4 & PHP5 simultaneously without using CGI or renaming files :) –  kolypto Nov 17 '09 at 9:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.