2 php.ini files

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 07:37:17

问题


I have found that:

When I type the following on terminal:

php -i | grep php.ini

I get the output:

The Loaded Configuration file is @ /etc/php5/cli/php.ini

However, from phpinfo(), I get to see:

The loaded ini file is @ /etc/php5/apache2/php.ini

Which one of these is working right now? How is it possible to have two php.ini files ?


回答1:


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.



来源:https://stackoverflow.com/questions/3871768/2-php-ini-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!