Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

Your Answer


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