If you’ve installed PHP in /usr/local as many people do, then your php.ini file is in /usr/local/php/lib. If you’ve installed PHP somewhere else, then you’ll find it in the corresponding lib directory. For instance, I like to put PHP in /opt/php5, so my php.ini file is in /opt/php5/lib.
There are a few other places it may be depending on platform. For instance, on Windows the Registry key HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath may contain a non-default location. On Unix the
PHPRC environment variable can point to a non-default location. (However remember this is an environment variable for whatever user the web server runs as, likely not the same as your personal user account’s environment variables.)
You can use the locate command on most Unix’s or the Finder’s File/Find… on Mac OS X to look for it. However the most reliable way to locate it is to use the
phpinfo() function from within a PHP page. Just place the following script in an info.phtml file somewhere on your web server, and load it in your browser:
<?php phpinfo(); ?>
Nothing else needs to be in this file. These three lines are enough. The file name doesn’t matter as long as it’s recognized as a PHP file.
About the sixth row of information dumped is “Configuration File (php.ini) Path” and this should tell you exactly where to look.
You may not actually see it in in any of these directories, including the one where PHP says it is. If so, you probably don’t have one. php.ini is not installed by default. You can create one in that directory using any text editor, though you may have to be root or use
to do so.