Where php.ini is loaded from
Once you have sucessfully installed PHP on IIS you'll find it is a highly configurable environment. Since PHP 4 all your master level configuration directives have been stored in a file called php.ini as touched on briefly in my PHP installation guide linked to earlier. Once you have configured you directives in this file the next trick is to ensure that it is loaded by your PHP environment which can be done several different ways which will be discussed in this article.
The methods and pecking order in which you can specify the location of your php.ini file for IIS are as listed below;
- The "-c" command line option in CGI and CLI
- The PHPRC environment variable as mentioned in the PHP installation guide on this site. This was checked after the registry keys listed below prior to PHP 5.2.
- The following registry locations are searched in the order they are listed as of PHP 5.2: HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z\IniFilePath, HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y\IniFilePath and HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x\IniFilePath, where x, y and z mean the PHP major, minor and release versions.
- The HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath Windows Registry location
- Current working directory (except CLI)
- Windows directory (e.g. C:\windows or C:\winnt)
As you can see these settings in PHP 5.2 give you quite a bit more flexibility on how you call your php.ini file over previous versions of PHP, and it even allows you to run different versions of PHP with their own php.ini file. Hopefully this guide should help if you are having trouble with the settings you are placing in your php.ini file not becoming effective. If not, please feel free to post a question or comment here or in the forums.
- 1363 reads









Post new comment