php.ini:哪个? [英] php.ini: which one?

查看:73
本文介绍了php.ini:哪个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从旧的Apache迁移到了Nginx和php 5.3.10.当我尝试修改php.ini以适合自己的需求时,我发现其中有3个:

I moved from my old apache to nginx and php 5.3.10. And when I tried to modify php.ini to suit my needs, I found there are 3 of them:

$ locate php.ini

/etc/php5/cgi/php.ini
/etc/php5/cli/php.ini
/etc/php5/fpm/php.ini

我应该编辑哪个?

推荐答案

通常来说,当从命令行调用PHP二进制文件时,将使用cli/php.ini文件.
您可以从命令行检查是否正在运行php --ini.

Generally speaking, the cli/php.ini file is used when the PHP binary is called from the command-line.
You can check that running php --ini from the command-line.

fpm/php.ini -在nginx安装中就是这种情况.
您还可以检查是否从您的网络服务器提供的php页面中调用phpinfo().

fpm/php.ini will be used when PHP is run as FPM -- which is the case with an nginx installation.
And you can check that calling phpinfo() from a php page served by your webserver.

cgi/php.ini很可能不会使用.


经常使用两个不同的php.ini文件(一个用于CLI,另一个用于从Web服务器提供页面),它具有一个主要优点:它允许您在其中使用不同的配置值.每种情况.


Using two distinct php.ini files (one for CLI, and the other one to serve pages from your webserver) is done quite often, and has one main advantages : it allows you to have different configuration values in each case.

通常,在网络服务器使用的php.ini文件中,您将指定一个较短的max_execution_time:应该快速提供网页,如果页面需要几十秒的时间(默认情况下为30秒),这可能是由于错误所致-应该停止页面的生成.
另一方面,您可以从crontab中启动相当长的脚本(或手动启动),这意味着将使用的php.ini文件是cli/中的文件.对于这些脚本,您在cli/php.ini中指定的max_execution_time比在fpm/php.ini中指定的更长.

Typically, in the php.ini file that's used by the web-server, you'll specify a rather short max_execution_time : web pages should be served fast, and if a page needs more than a few dozen seconds (30 seconds, by default), it's probably because of a bug -- and the page's generation should be stopped.
On the other hand, you can have pretty long scripts launched from your crontab (or by hand), which means the php.ini file that will be used is the one in cli/. For those scripts, you'll specify a much longer max_execution_time in cli/php.ini than you did in fpm/php.ini.

max_execution_time是一个常见示例;当然,您可以对其他几个配置指令执行相同的操作.

max_execution_time is a common example ; you could do the same with several other configuration directives, of course.

这篇关于php.ini:哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆