Tuesday, May 26, 2009

PHP & IIS - INI File Location

OK, so normally I wouldn't be seen dead running PHP on Windows but I'm currently doing some odds and ends for MiCandidate and one of the things they needed was to run some PHP code in their otherwise ASP.NET based site.

One of the ASP.NET developers attempted to install the current release of PHP (5.2.9-2), first from the MSI and then using the ZIP package but in the end failed to get their customised php.ini file to load.

After a less than delightful morning of reading and testing, I have discovered the following. The phpinfo() function will apparantly always return a value of 'c:\windows' for the configuration file path setting.

The important thing to note here though is where the ini file is being loaded from. By default it will load it from the PHP installation directory. If you want to to load from somewhere else, like say, the windows directory, you must first edit the registry and add/change the following key:


setting its value to 'c:\windows\'

However, this is not enough to force PHP to load this file. You must also ensure that you have removed any copy of php.ini from the installation directory too before the registry setting is respected.

It is also worthwhile noting that you need to ensure that your PHPRC environmental variable is set to your PHP installation folder (usually c:\php).

Finally, it is a good idea to set up a separate application pool in IIS to run PHP so you can just recyle that to see the changes made in php.ini. This obviously minimises distrutpion for other developers using the server.

This experience did nothing to enamor the ASP.NET developer to PHP and I wonder why the MSI installer can not take care of these issues gracefully.

No comments:

Post a Comment