2 php.ini files

后端 未结 1 1428
臣服心动
臣服心动 2020-11-27 18:09

I have found that:

When I type the following on terminal:

php -i | grep php.ini

I get the output:

The Loaded

相关标签:
1条回答
  • 2020-11-27 18:39

    Depends on where you are running PHP from. If you run it from command line, it uses the cli/php.ini and apache2/php.ini when run through apache.

    You are executing phpinfo() through the browser, hence you get /etc/php5/apache2/php.ini as the answer. Running php -r "phpinfo();" | grep "Loaded Configuration" from the terminal should output the CLI ini. Same function, context changes.

    The advantage of this system is obviously to allow different configurations depending on the context. For a simplified example, you might want to have safe_mode on in apache but it's unnecessary in CLI mode.

    Your .ini paths are actually quite unusual. Normally, the default .ini is just php.ini and CLI .ini is called php-cli.ini and they reside in the same folder.

    I'm no expert on the subject but this should be the basic idea. If anyone has any corrections, I'd be happy to hear them.

    0 讨论(0)
提交回复
热议问题