5

I'm using Magento 2.3.0 with PHP 7.2.15-0ubuntu0.18.04.1 (cli) (built: Feb 8 2019 14:54:22) ( NTS ), and I'm not sure which is the php.ini file that I should modify. I am currently modifying these two with the same information:

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

But I guess the system only use one of the two, where can I check which of the two files is the one using the system?

4

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)

  • Thank you very much for your master class! I was going crazy because it is what you say, since the phpinfo () it appeared to me that it used the /fpm/php.ini and from the php --ini it appeared to me that it used the /cli/php.ini. Therefore, it is normal to edit both files with the configuration that Magento needs (the same information in both files), right? – Despotars Mar 4 at 18:02
  • 1
    There are some cases where you don't need to have the exact information in both of the files (like memory allocation for example), but more often than not, you want to edit both files. – Dan Mar 5 at 0:09
2

check phpinfo();

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

  • Yes but when I created the fie, I have this error: 404 error: Page not found php – Despotars Mar 4 at 10:25
  • 1
    This is because of your magento .htaccess file. For testing purpose, you need to edit your project index file. pub/index.php and add phpinfo();die; there on top of the file – Shoaib Munir Mar 4 at 10:27
  • 1
    Welcome..... :) – Shoaib Munir Mar 4 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.