We help IT Professionals succeed at work.

Setting Up PHP4 and PHP5 together on Windows XP.  Both using C:\PHP5\php.ini.

steverey443
steverey443 asked
on
1,595 Views
Last Modified: 2013-12-13
I'm trying to get PHP4 and PHP5 both running on XP.  I have PHP4 running but it is using the the following php.ini: "c:\PHP5\php.ini".

I've tried putting the php.ini path in the registry and restarting IIS but there is no change.

There is no php.ini in the c:\windows directory.

How do I get PHP4 to use the c:\PHP4\php.ini and PHP5 to use the c:\PHP5\php.ini?


*********  Results of phpinfo() ***************
System  Windows NT ACTIONSLACKS64 5.1 build 2600  
Build Date  May 4 2007 13:29:21  
Server API  ISAPI  
Virtual Directory Support  enabled  
Configuration File (php.ini) Path  C:\PHP5\php.ini  
PHP API  20020918  
PHP Extension  20020429  
Zend Extension  20050606  
Debug Build  no  
Zend Memory Manager  enabled  
Thread Safety  enabled  
Registered PHP Streams  php, http, ftp, compress.zlib  
**************************************************************

*******   Contents of HKEY_LOCAL_MACHINE\SOFTWARE\PHP ************
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"InstallDir"="c:\\PHP4"
"ApacheDir"="C:\\"
"IniFilePath"="c:\\php4"

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5]
"IniFilePath"="c:\\php5"
**************************************************************

*************** Path ***************************************
PATH=C:\Perl\site\bin;
C:\Perl\bin;
C:\PROGRA~1\GTK\bin;
C:\Perl\bin\;C:\Program Files\Windows Resource Kits\Tools\;
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322;
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;
C:\Python24;
c:\Program Files\Microsoft SQL Server\90\Tools\binn\;
[INSTALLDIR;"C:\Program Files\Zone Labs\ZoneAlarm\MailFrontier";;C:\
Program Files\Windows Imaging\;
c:\php4;
C:\PHP4\extensions;
c:\PHP5;
C:\PHP5\ext;
C:\Program Files\OpenVPN\bin
**********************************************************************************
Comment
Watch Question

Author

Commented:
This same question was accidently posted under a different user "dianwells" by me.  This is the correct question.  I've requested that the other one be closed.

Thanks
Steve
Top Expert 2007

Commented:

Author

Commented:
I got it to work but am still not clear on how the two php versions, php4 and php5, decide which php.ini file to use.

I have the PHP5 version of the php.ini in c:\windows\php.ini and the PHP4 version in c:\php4\php.ini.  With no changes from the above config they are each finding the correct version.

I was able to do this by renaming the c:\php5\php.ini so php4 wouldn't find it.  Not clear on why it was finding c:\php5\php.ini first since c:\php4 comes first in the path statement.

Still open if someone can tell me how to explicitly tell each version which .ini file to use.  My understanding was that using the following registry settings would accomplish this but it does not work.

*******   Contents of HKEY_LOCAL_MACHINE\SOFTWARE\PHP ************
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"InstallDir"="c:\\PHP4"
"ApacheDir"="C:\\"
"IniFilePath"="c:\\php4"

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5]
"IniFilePath"="c:\\php5"
**************************************************************

Author

Commented:
Increasing Points to 500.
Senior Software Developer
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Richard QuadlingSenior Software Developer

Commented:
PHP4 only understands ...

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"IniFilePath"="C:\\PHP_INI"

PHP5+ allow for

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5]
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5.2]
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5.2.4]
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5.2.4RC1-dev]

for example.

Author

Commented:
Thanks RQuadling:

I added a registry key for my version

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5.2.4]

The main thing that fixed it though was taking the ini files out of the path.
c:\PHP_INI\PHP4
c:\PHP_INI\PHP5

Each version is now loading the files I tell it to.

Thanks
Richard QuadlingSenior Software Developer

Commented:
I would recommend just using [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5] as an upgrade to PHP5 (say PHP 5.3) will suddenly stop working!

Author

Commented:
Excellent point.  I am using the following and have no php.ini files in the path.  This works great and allows for upgrades.  Having one or mor php.ini files in the path gave me unexpected results.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"IniFilePath"="C:\\PHP_INI"

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5]
"IniFilePath"="C:\\PHP_INI\\PHP5"
Richard QuadlingSenior Software Developer

Commented:
I don't have the INI files in the path. I have my PHP5 installation in the path as I use it for CLI work.

Author

Commented:
Sorry I wasn't clear.  When I saw that your PHP.ini files were not in the PHP program directory (C:\PHP4, and C:\PHP5) I realized that they were likely not in the path.  I moved my php.ini files out of my path to C:\PHP_INI\PHP4\php.ini and C:\PHP_INI\PHP5\php.ini and that fixed the issue for me.

Moving the php.ini files out of the path and referencing them in the registry was the final solution!

Thanks for the help.

Thanks for the help.
Richard QuadlingSenior Software Developer

Commented:
Ha. Yes. Sorry. I didn't make it clear that the registry had to point to where the INI files are - or - the ini files had to be moved to where the registry said they should be.

Author

Commented:
Ha.  No I got that.

In my origional configuration the correct registry settings were set but the ini files they pointed to, c:\php4\php.ini and c:\php5\php.ini, were also in the system path.  Both versions of PHP would end up using c:\php5\php.ini for some reason.

When I moved the files to a location outside of the system path, made sure there were no php.ini files in the system path (c:\windows, c:\php4, c:\php5), and updated the registry settings to reflect their new location each version of PHP used the proper .ini file as indicated in the registry.

If I left any php.ini files in the system path (c:\windows, c:\php4, c:\php5), PHP4 would end up using one of these instead of the one set in the registry.

So in my case locating the php.ini files outside the system path as well as referencing their location in the registry was my solution.  

The fact that you used a seperate directory (C:\PHP_INI) gave me the idea to move the files to a location outside the system path and it worked like a charm.

Richard QuadlingSenior Software Developer

Commented:
NP.

Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.