2个php.ini文件

发布于 2024-09-26 03:46:46 字数 310 浏览 3 评论 0原文

我发现:

当我在终端上输入以下内容时:

php -i | grep php.ini

我得到输出:

加载的配置文件是@ /etc/php5/cli/php.ini

但是,从 phpinfo() 中,我看到:

加载的ini文件为@ /etc/php5/apache2/php.ini

其中哪一个现在正在工作?怎么可能有两个 php.ini 文件?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不知在何时 2024-10-03 03:46:46

取决于您从何处运行 PHP。如果从命令行运行它,则在通过 apache 运行时它会使用 cli/php.iniapache2/php.ini

您正在通过浏览器执行 phpinfo(),因此您将得到 /etc/php5/apache2/php.ini 作为答案。运行 php -r "phpinfo();" |终端中的 grep "Loaded Configuration" 应输出 CLI ini。相同的功能,上下文发生变化。

该系统的优点显然是允许根据上下文进行不同的配置。作为一个简化的示例,您可能希望在 apache 中启用 safe_mode,但在 CLI 模式下则没有必要。

您的 .ini 路径实际上很不寻常。通常,默认的 .ini 只是 php.ini,CLI .ini 称为 php-cli.ini 并且它们驻留在同一文件夹中。

我不是这个主题的专家,但这应该是基本想法。如果有人有任何更正,我很乐意听到。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文