Here’s a quick tip on how to locate the php.ini configuration file which is currently in use by PHP on your system or web host.
Locate PHP.ini From the Command Line
You can usually find out which php.ini file PHP is pulling its configuration from from the command line. The php -i command will print the information about your current PHP environment and grep will filter that output to only lines containing the string ‘Configuration File’, including it’s location:
php -i | grep 'Configuration File'
Finding the PHP.ini Configuration in Use for a Web Host
It is possible that your web server is using a different php.ini file to the one used for the whole system/command line – different virtual hosts may even be using different configuration files themselves. This is particularly common in shared hosting scenarios.
In this case, create a PHP file containing the following code:
<?php var_dump( get_cfg_var('cfg_file_path') ); ?>
When accessed from a web browser, it will print the location of the php.ini file in use for that web host.