Which php.ini is used on my system?

I want to clarify the difference, as the 2 files are not redundant and you may still need to modify both files in most cases. Especially since some times, we use the command line to run some Magento commands.

As the other answers mention, running phpinfo() will let you know which php.ini file you would be using. However, the two files exist for two separate purposes.

  • /etc/php/7.2/fpm/php.ini

    This file will be used by your web server. So running phpinfo() in a PHP file which gets served by your web browser, will show you this ini file.

  • /etc/php/7.2/cli/php.ini

    This file will be used by the command line (CLI is an acronym for Command-Line Interface). So running commands in the CLI will, in fact, use this ini file and not the other one. It should be possible to verify this by running php -i in the command line (I don't have PHP installed on the OS I'm currently using in order to test the command).

So as you can see, if for example, you enable an extension in the fpm/php.ini because Magento needs it, you will find that the magento CLI command would fail and complain if you don't also enable that module in the second file as well. (It may be a better idea to enable PHP extensions in another way, like php7.2enmod in Ubuntu, but this is just an example)


check phpinfo();

you will see "Configuration File (php.ini) Path" in info list, this is where you find php.ini file path