it seems that some of my php applications require php 5.2 and some require php 5.3. is there a way to configure apache (v2.2.14) that one virtualhost will work with one php library and a different virtualhost will require a different one?

currently the only solution that i found is to install two apaches and two phps and each of the apache will reside in a different port.


  • 1
    Poor application design if people are coding for a point release rather than a major release. Generally, point releases shouldn't have breaking changes in them. – Chris Jan 18 '10 at 13:04
  • Have you tried running the PHP 5.2 app on PHP 5.3? – ceejayoz Jan 18 '10 at 15:31
  • 1
    While point release SHOULDN'T have breaking changes the reality is that PHP 5.3 does indeed break code that runs perfectly on 5.2. – John Gardeniers Jan 18 '10 at 21:51
  • 1
    Some versions of Drupal 5.x won't run properly on PHP 5.3... Thanks... – tegbains Jan 18 '10 at 22:00

If you would use PHP 4 and 5 it would be easy to manipulate what module you want to use with:

<IfModule mod_php5.c> 
<IfModule mod_php4.c> 

So there 3 ways to deal with this problem:

  1. Correct the problems in the PHP scripts (imho the best way)
  2. Modify the PHP source code so it reports itself as "mod_php52.c","mod_php53.c"
  3. Run it as CGI where needed Check it out here

You can also run 2 servers on different ports and use a proxy

  • You link is 404 – Jarco Feb 2 '17 at 12:55

Yes it is possible. You should use fastcgi mode by "FcgidWrapper" directive in apache configuration. This way you can define different fastcgi handler daemons for different url extension, path, or even virtual hosts. In the background, each fastcgi daemon then can easily executes different php versions.


I use PHPfarm to run many PHP versions on one apache instance. Works absolutely fine.

You basically install alternative PHP versions as CGI and use them to handle .php files in certain vhosts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.