A roundup of links on how to run PHP4 and PHP5 on the same server;
- Via PHPKitchen: Running PHP 4 and PHP 5 Concurrently
John Coggeshall explains, using two Apache instances, Apache’s mod_proxy and a virtual host.
- Via Planet PHP: PHP5 CGI parallel to PHP4 module on Windows
Urs Gehrig explains. This is probably about the quickest and easiest way to get them running together. Of course PHP as a CGI is not quite the same as an Apache module, performance / $_SERVER variable-wise. Urs also has a handy page of links on PHP5 Installation and related here.
- Via Bitflux: How to run PHP4 and PHP 5 parallel
Tobias Schlitt explains how to get both running as apache modules under Linux.
Any more?











March 24th, 2004 at 11:11 am
What about IIS ? :D
March 24th, 2004 at 11:54 am
Cool beans, if you are running apache. Has anyone got it running in paralell on IIS. In particular, what should you do with php.ini and the dlls, which seem to need to overwrite each other.
March 24th, 2004 at 4:00 pm
Yep, I am another IIS user :D Would really like to have a look at v5.
Anyone have any ideas ?? Thx.
March 25th, 2004 at 5:28 pm
For IIS, I guess the CGI approach may be best for PHP5 while using the isapi module for PHP5. You might point the PHP5 CGI at files ending with .php5
March 26th, 2004 at 8:13 am
Thanks Harry, though I have no plans to run both a CGI and asapi IIS :) Very ugly as I see it :eek2:
Just need to get a hold of another box I suppose huh ? :)
March 26th, 2004 at 9:49 am
The problem is not running it as a CGI vs ISAPI extension. Both will theoretically work.
The problem is the PHP.INI file and the DLLs, which are different but need to be in the same places as far as I can figure out. Right now php5 is setup, but it will not initialize because of version mismatches in libraries.
WWB
March 30th, 2004 at 3:30 pm
Hi all,
For those who want to know how to configure PHP 4 and 5 on a IIS server, I wrote an article about it (in french). Here is the google translation: http://translate.google.com/translate?u=http%3A%2F%2Fmiasmatik.maladoc.org%2Fdoc.php%3Fd%3D6&langpair=fr%7Cen&hl=fr&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools
This article explain how to configure and run simultaneously PHP 4.0.6, PHP 4.3.3 and 5.0.0 beta on Apache and IIS on the same box. Most of this configuration is based on CGI version, virtual hosts for Apache and virtual directories for IIS.
April 11th, 2004 at 9:54 am
About php.ini in Windows
As explained there in French (http://tw.o0o.ch/weblog/2004/04/11/47-php-4-et-5-histoire-d-une-cohabitation), the CGI looks for this file in its own directory before looking in windows directory. So you can have two php.ini files : one in the windows dir for the module, and one other in the cgi dir for the cgi…
June 19th, 2004 at 12:10 am
Parallel Instances of PHP on Windows (http://blog.ajohnstone.com/index.php?p=8)
July 23rd, 2004 at 4:10 am
You can run PHP 4.3.8 and PHP 5.0.0 and the same windows server with WAMP5 :
http://www.en.wampserver.com
And add-on installs PHP4 and lets you swithc from one to another…
October 18th, 2004 at 4:57 pm
can you run php4, php5 and plesk in parallel
December 11th, 2004 at 4:48 am
Also, as mentioned at http://www.php.net/manual/en/install.windows.manual.php, you can specify the PHP.INI path by adding a value to the following key
or create an environment variable by name of PHPRC.
But then I guess that doing so will also make PHP4 load PHP5’s ini file. :(
January 16th, 2005 at 3:26 pm
To daveah:
I’m running plesk 7 reloaded and taking a quick look at the above tutorials, it seems you should be able to install a separate PHP4/PHP5/MySQL/Apache install without any problems as plesk installs it’s own specific files and programs into it’s own directory (/usr/local/psa/ on my freeBSD box).
Well… time to try it out…
March 25th, 2005 at 5:29 pm
For IIS 6 people on Windows Server 2003, one of the PHP dev team members shared these instructions (which aren’t in a manual, and I haven’t tested):
http://bugs.php.net/bug.php?id=28448&thanks=6
I know it works for the PHP 5 part, though, which is really all you need.
Also, asp_funda, I saw that too, a supposedly that registry key is only for PHP 5, thus you “should” be able to make PHP 4 and 5 look at different config files that way. I haven’t tested that, either.
March 25th, 2005 at 5:30 pm
Oops, I left the “&thanks=6″ in that URL above. If you follow that link, you haven’t actually voted for anything. :)
April 4th, 2005 at 4:35 pm
I’ve returned to say that this is entirely possible, and I have it running under IIS 6 on W2K3 right now (PHP versions 5.0.4 and 4.3.11). There are a couple caveats:
If you use the registry key trick, see my bug report on how that works here: http://bugs.php.net/bug.php?id=32576
Make absolutely sure to set everything perfect under IIS, and issue frequent iisreset commands as you debug. See this blog post (well, my comment on it moreso) http://www.aplus.co.yu/trends-rants/open-source-mine/#comment-1983
April 6th, 2005 at 10:39 am
Ok, I lied. After a day of running these in “parallel”, I realized that the registry trick doesn’t actually work. It’s undocumented, but PHP 4 does look for that registry key as well. I noticed that in phpinfo() under PHP 4, it was reading my PHP 5 config. It’s not so bad though - although trying to run PHP 5 with a PHP 4 version ini file will not work, you can do the opposite.
What sucks is that I also tried the instructions by the PHP dev I posted a couple comments ago. This didn’t work either. PHP never looked in its own directories for the ini file. I made a comment on the bug page but I expect it to get deleted or ignored, as I haven’t had much luck with bugs.php.net in general.
So my determination is that it is simply not possible to run PHP 4 and 5 in parallel under IIS 6 on Windows Server 2003. If someone does get it, please post a (legit) screenshot of two browser windows showing phpinfo(), and tell us all what you did. In my case, I just took my server offline, upgraded to php 5, worked out a couple issues, and put it back.
October 21st, 2005 at 2:20 pm
IIS6=no problem.You can use any of the above methods or just a separate application pool.
IIS5 you have to do the following:
copy php4 into one folder say…c:\php4 and php5 into c:\php5
put the php.ini-s into those folders(NO PHP.INI IN THE WINDOWS FOLDER!!!)
then make sure all the dlls(including support dlls for mcrypt and stuff that ARE compatible with these php versions)are also in these folders AND AGAIN NOT IN THE WINDOWS FOLDER.
DO NOT put any of these 2 folders in the SYSTEM OR USER PATH enviorment.
final step is to use a separate application name in iis and setup the .php extension to use the cgi-version of whichever php version you want.
I’m guessing this should also completely work on iis6.
And as far as other iis6 HOWTOS and everything i’ve read on the net they are ALL 2 long and include unneeded steps.I had it running pn iis6 in five minutes and none of those were needed.
So to the people writting them:”PLEASE TEST THE MINIMUMS NEEDED TO GET IT RUNNING BEFORE YOU WRITE THOSE” because all the steps you took that day before you got it running might be completely unneeded.
Good luck.
December 20th, 2005 at 2:19 am
Hi,
I am bundling Apache 1.3.x and Php 4.4 with my product.
I configured Php as module in C:\program files\php\.
My php.ini is at C:\program files\apache\ dir.
I also have another apache and php instance at C:\program files\apache\ and C:\php\ locations. Its php.ini is at C:\Windows.
After intalling my product, I installed Zend Studio Server [ZSS]and configured php.ini path as C:\windows\php.ini. ie, my second php instance.
Now, after restarting my products apapche server, the php_ini path shows as c:\windows. Before installing ZSS, it shows correctly.
How to locate my php.ini for my products apache & php configuration. I tried PHPIniDir & SetEnv.. option. Obviously both will not working in my case.
Any ideas.?
–
Thanks in advance,
Nova.
February 16th, 2006 at 1:38 am
see also this page : (though very gentoo/linux oriented) http://www.gentoo.org/proj/en/php/php4-php5-configuration.xml
March 25th, 2006 at 2:49 pm
php.exe (PHP4) i php-cgi.exe (PHP5) search for php.ini in their directories first. PHPRC does not matter.
Use Fast-CGI, I got it working. Have PHP5 working with .php5 extension. For PHP4 I use old .php extension.
Put isapi_fcgi.dll in your PHP4 dir, configure IIS to use this DLL: add to allowed extensions and configure mappings to use this dll. Add .php5 mapping using this dll (still in PHP4 dir, do not copy isapi_fcgi.dll to PHP5 dir).
Then add the Fast-cgi registry entries as usuall, but add one more for .php5 with Apppath pointing to php-cgi.exe in PHP5 dir. You can also add Arg entry with “-c C:\PHP5\php.ini” if you want to be extra sure.
I even added eAccelerator to this config, but it can work with PHP4 OR PHP5, not both (memory share problem).
The only problem with this is that you have to monitor processes, because when w3wp fails, php.exe and php-cgi.exe spawned by Fast-CGI dll might not get killed, so when w3wp restarts it spawns more php.exe processes.
March 25th, 2006 at 2:55 pm
I forgot:
PHP4 is in PHP dir, PHP5 is in PHP5 dir, NO FILES in Windows folders. So when Fast-CGI spawns php.exe it finds all it needs in its own directory. Same for php-cgi.exe (PHP5).
This setup works with Zend Optimizer 2.6.2 installed. Each PHP loads appropriate dll from Zend folder.
Use phpinfo.php and phpinfo.php5 in two browsers to verify all works fine.
Good luck.
April 25th, 2006 at 3:52 am
The link on Tobias Schlitt’s site has temporarily been changed to this.
November 9th, 2006 at 11:46 am
How to run dual PHP instances with PHP 5.2 and any previous PHP in Windows 2003:
1. Right-click My Computer, go to Advanced tab, and click on Environment Variables.
Add the two installations and their EXT directories to the Path variable. For example, add:
c:\php;c:\php\ext;c:\TMAS\php;c:\tmas\php\ext;
Then, add the newer PHP version’s directory as a variable called PHPRC. For example:
Variable:PHPRC
Value: C:\PHP
Click OK to close the Environment Variables window, and click OK to close System Properties.
2. In registry, under HKEY_LOCAL_MACHINE>SOFTWARE>PHP, add a REG_SZ key called iniFilePath and give it a value
of the directory where the older PHP is installed. For example:
C:\TMAS\PHP
3. In IIS, go to the Web Service Extensions. Add both versions’ ISAPI module separately to the extensions
list, and allow both.
4. In IIS, go to each website utilizing the PHP versions. Set an ISAPI filter if needed. On the Home Directory
tab, click Configuration, and add .php, .php3, .phtml, and any other extensions needed (perhaps .html?) to
be filtered through PHP, and specify the ISAPI module version needed for each website.
You can now run two versions of PHP. This is because the order of where to look for the .ini file changed
between previous PHP versions and PHP 5.2, as documented at http://us2.php.net/ini:
—————————————————
php.ini is searched in these locations (in order):
* SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)
* The PHPRC environment variable. Before PHP 5.2.0 this was checked after the registry key mentioned below.
* HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry location)
* Current working directory (for CLI)
* The web server’s directory (for SAPI modules), or directory of PHP (otherwise in Windows)
* Windows directory (C:\windows or C:\winnt) (for Windows), or –with-config-file-path compile time option
—————————————————-
April 22nd, 2008 at 7:28 am
Check this great tutorial on how to install PHP4 and PHP5 on Apache on Windows XP both on port 80.
How to install PHP4 and PHP5 on Apache on WindowsXP
July 8th, 2008 at 6:51 am
Looks like All your links are broken now.