Find where php.ini is located

in Linux, PHP, Console

So you're enjoying your Webserver features, when you realize you need to change something pretty basic, such as the memory limit of PHP. That of course, is set through php.ini ... but where is that file located?

Different distributions place it in different locations, but there is always an easy way to get it.

Fastest way of course, is via your trusty shell:

php -r 'phpinfo();' | grep php.ini
It's also good to know that you can findany information normally present in phpinfo via this way, simply by changing grep's argument (php.ini in the above example). Try replacing it with max_upload!

I guess you could be unimaginative, and make a dummy web page that calls upno phpinfo() and then search through the page... but that's just too much work!

Do note that in some Linux flavors, a different php.ini is used for CLI and Apache. If that is the case, the above method will only show the configuration file used for CLI