PHP4 and PHP5 w/ IIS6.0 and Win Server 2003 (HKEY_LOCAL_MACHINE\...\IniFilePath vs. PATH vs. PHPRC) concurrent installation

My environment:
  Windows Enterprise Server 2003
  MS SQL2000

I would like to create a nice integration development environment in the same machine that supports IIS -> PHP -> (Mysql or MSSQL) in the same server

I've had a very hard time getting PHP4 and PHP5 running concurrently. The closest that I was able to get it was to

Unpack all php 4 into c:\httpd\php4
copy all files from c:\httpd\php4\sapi\* and dll\* into c:httpd\php4 directory (i.e. move up one directory)
Unpack all php 5 into c:\httpd\php5
Set the administration PATH env variable to PATH=...;c:\httpd\php5\;c:\httpd\php4
Go to IIS -> Web Service Extensions - > Add New Extension (1) for PHP pointing to c:\httpd\php4\php4isapi.dll and (2) for PHP5 pointing to c:\httpd\php5\php5isapi.dll
Go to IIS -> Web Sites -> [Properties]  -> Home Directory -> Configuration... -> add mappings .php5 to php5isapi.dll and .php to php5isapi.dll
edit php.ini-recommended on each directory (i.e. php4 and php5) only uncommented several dynamic extensions and, cgi.force_redirect = 0, and extension_dir = "c:\httpd\[php4 | php5]\ext\"
Cold boot

While I can get both php to respond correctly, I cannot see any dynamic extensions loaded.


Under the above arrangement which php.ini is being use for php5? At one point I deleted php.ini and it made no difference.

I have opted to set PHPRC = c:\httpd\php5 which does ready the php.ini and loads my extension correctly. However I break php4. What to do?



Who is Participating?
Richard QuadlingConnect With a Mentor Senior Software DeveloperCommented:
The ini file needs to be called php.ini, even though they come with -recommended and -dist.

Also, php.ini needs to reside in the %windir% directory (C:\WINDOWS, C:\WINNT, or wherever).

I'm not an IIS user (I use Sambar Server I also only use PHP5.0.1 now.

An assumption.

I would assume that if you were to develop a site, you would use PHP4 OR PHP5. Not both.

If so, the site itself would be the determining factor on whether to use PHP4 or PHP5?

If so, does IIS support a method where you can set the php.ini path in a something like a .htaccess file? I may have all the terminology mixed up here (I don't use .htaccess either!).

I've seen .htaccess used to control PHP's behaviour.

Also, I've just looked through the PHP manual ...

Changing PHP configuration via the Windows registry
When running PHP on Windows, the configuration values can be modified on per-directory basis using the Windows registry. The configuration values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory Values, in the sub-keys corresponding to the path names. For example, configuration values for the directory c:\inetpub\wwwroot would be stored in the key HKLM\SOFTWARE\PHP\Per Directory Values\c\inetpub\wwwroot. The settings for the directory would be active for any script running from this directory or any subdirectory of it. The values under the key should have the name of PHP configuration directive and the string value. PHP constants in the values would not be parsed.

I'm not sure how useful this will be.

Take a look at ...

The downside here is that it uses CGI rather than ISAPI. So no persistent DB connections.

On one of the pages on this site ...

"Note: with Microsoft IIS, it appears that the php.ini located in the php.exe directory is not taken into account and that PHP seeks it in C:\WinNT. This not existing file, it is the built-in configuration which is taken into account (which is defined within compiled php.exe). This problem does not occur under Apache."

So, maybe drop IIS and go for Apache.


UmeshMySQL Principle Technical Support EngineerCommented:
osaezAuthor Commented:
I did. First, this article is rather old. Secondly, their suggestion is to make one PHP run under ISAPI and another under FastCGI. I'm still confused as to what php.ini is used by the php5isapi.dll if I don't use the registry or the PHPRC. This is the real question.
Using Filemon ( you can easily figure out non-standard names for php.ini. For example, in my case (Windows Server 2003, Apache 2.0.50, PHP 5.0.0) in place of  the default "c:\windows\php.ini" I use "c:\Program Files\Apache Group\Apache2\php-apache2handler.ini" and it works perfectly (actually, this location is the first php looks for).

To test which *.ini file can be used, use the Filemon utility and add a filter setting the "Include" option to "*php*ini*" and leaving two other blank. Then start Apache, view any *.php page from your server in browser, and watch the output from the Filemon utility.

You might also want to take look at this:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.