您的位置:首页 > 编程语言 > PHP开发

PHP5.6 配置文件php.ini详解(译版)

2017-11-16 16:26 435 查看
[PHP]

; 声明:ini文件来源phpstudy,翻译主学习参考。未完待续,所有翻译完了后将会把译文做高亮处理。

;;;;;;;;;;;;;;;;;;;

; About php.ini ;

;;;;;;;;;;;;;;;;;;;

; PHP’s initialization file, generally called php.ini, is responsible for

; configuring many of the aspects of PHP’s behavior.

;;;;;;;;;;;;;;;;;;;

;关于php.ini;

;;;;;;;;;;;;;;;;;;;

; 这个文件必须命名为’php.ini’并放置在httpd.conf中PHPINIDir指令指定的目录中。

; php.ini在PHP启动时会被启动。对于服务器模块版本的PHP,仅在web服务器启动时读取一次,对于CGI和CLI版本,每次调用都会读取。

; Web服务器一般指网站服务器,是指驻留于因特网上某种类型计算机的程序,可以向浏览器等Web客户端提供文档,[1] 也可以放置网站文件,让全世界浏览;可以放置数据文件,让全世界下载。目前最主流的三个Web服务器是Apache Nginx IIS。

; CGI && CLI 是php运行模式其中的两种。

; CGI :“公共网关接口”(Common Gateway Interface),HTTP服务器 与你的或其它机器上的程序 进行 “交谈”的一种工具 ,其程序 须运行在网络 服务器 上。在服务器 环境中,为“程序 ”提供标准 的接口,通过这个接口,“程序 ”可以对服务器 与客户端 交换的信息 做一些事情 。“程序 ”的语 言并没有要求。程序 对接口进行 操作。服务器 要支持 CGI就要提供CGI中要求的环境变量 ,或者还有别的。我的理解至此为之。

; CLI :“ 命令 行界面”(Command Line Interface),可在用户 提示符下键入可执行指令 的界面。

; PHP attempts to find and load this configuration from a number of locations.

; The following is a summary of its search order:

; 当PHP运行的时候,PHP会尝试从多个位置下查找并加载此配置,下面是位置查找的顺序

; 1. SAPI module specific location.

; 1. SAPI模块的具体位置。

; SAPI 理解:在PHP生命周期各个阶段中,一些和服务相关的操作都是通过SAPI接口实现,这些内置实现的物理位置在PHP源码的SAPI目录下,这个目录存放了PHP对各个服务器抽象层的代码,例如命令行程序的实现,Apache的mod_php模块实现以及fastcgi的实现等等、

; 在各个服务器抽象层之间遵循着相同的约定,这里我们称之为SAPI接口。每个SAPI实现都是一个_sapi_module_struct 结构体变量。

; SAPI深入理解请前往 http://www.cnblogs.com/orlion/p/5157280.html

; 如果存在 php-SAPI.ini(SAPI 是当前所用的 SAPI 名称,因此实际文件名为 php-cli.ini 或 php-apache.ini 等),则会用它替代 php.ini。SAPI 的名称可以用 php_sapi_name() 来测定。

; 2. The PHPRC environment variable. (As of PHP 5.2.0)

; PHPRC 环境变量。在 PHP 5.2.0 之前,其顺序在以下提及的注册表键值之后。

; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0)

; 自 PHP 5.2.0 起,可以为不同版本的 PHP 指定不同的 php.ini 文件位置。将以下面的顺序检查注册表目录:[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z],[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] 和 [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x],其中的 x,y 和 z 指的是 PHP 主版本号,次版本号和发行批次。如果在其中任何目录下的 IniFilePath 有键值,则第一个值将被用作 php.ini 的位置(仅适用于 windows)。

; 4. Current working directory (except CLI)

; 当前工作目录(CLI下)

; 5. The web server’s directory (for SAPI modules), or directory of PHP

; (otherwise in Windows)

; Web 服务器目录(对于 SAPI 模块)或 PHP 所在目录(Windows 下其它情况)。

; 6. The directory from the –with-config-file-path compile time option, or the

; Windows directory (C:\windows or C:\winnt)

; Windows 目录(C:\windows 或 C:\winnt),或 –with-config-file-path 编译时选项指定的位置。

; See the PHP docs for more specific information.

; 查看PHP文档获取更详细的信息。(就是下面的链接)

; http://php.net/configuration.file

; The syntax of the file is extremely simple. Whitespace and lines

; beginning with a semicolon are silently ignored (as you probably guessed).

; Section headers (e.g. [Foo]) are also silently ignored, even though

; they might mean something in the future.

; 该文件的语法非常简单。空白字符和以分号开始的行被简单地忽略。章节标题(例如: [php])也被简单地忽略,即使将来它们可能有某种意义。

; Directives following the section heading [PATH=/www/mysite] only

; apply to PHP files in the /www/mysite directory. Directives

; following the section heading [HOST=www.example.com] only apply to

; PHP files served from www.example.com. Directives set in these

; special sections cannot be overridden by user-defined INI files or

; at runtime. Currently, [PATH=] and [HOST=] sections only work under

; CGI/FastCGI.

; http://php.net/ini.sections

; 配置项中的PATH路径值 = /www/mysite 只适合对应目录下的php文件。

; (后面这段还没理解到。。。)

; 更多的PHP配置段选项请前往 http://php.net/ini.sections 这段是php5.3.0增加的配置项,链接里有说明。

; Directives are specified using the following syntax:

; directive = value

; Directive names are case sensitive - foo=bar is different from FOO=bar.

; Directives are variables used to configure PHP or PHP extensions.

; There is no name validation. If PHP can’t find an expected

; directive because it is not set or is mistyped, a default value will be used.

; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one

; of the INI constants (On, Off, True, False, Yes, No and None) or an expression

; (e.g. E_ALL & ~E_NOTICE), a quoted string (“bar”), or a reference to a

; previously set variable or directive (e.g. ${foo})

; 在后面的描述中指令 = 配置项。;后面的INI常量、INI表达式,类似这种的都表示为该INI文件即这个php.ini文件下。

; 设置指令的格式如下:

; directive = value

; 指令名如’directive’大小写敏感。其值可以是用引号界定的字符(”)、数字(1,2.2,3)、PHP常量(E_ALL、M_PI)、INI常量(On,Off,none)、表达式(E_ALL &~ E_NOTICE)

; Expressions in the INI file are limited to bitwise operators and parentheses:

; | bitwise OR

; ^ bitwise XOR

; & bitwise AND

; ~ bitwise NOT

; ! boolean NOT

; INI文件中的表达式仅使用:位运算符、逻辑非、圆括号:

; | 位或

; & 位与

; ~ 位非

; ! 逻辑非

; Boolean flags can be turned on using the values 1, On, True or Yes.

; They can be turned off using the values 0, Off, False or No.

; 布尔标志用 On 表示打开,用 Off 表示关闭。

; An empty string can be denoted by simply not writing anything after the equal

; sign, or by using the None keyword:

; 一个空字符串可以用在等号后不写任何东西表示,或者用 none 关键字:

; foo = ; sets foo to an empty string

; foo = None ; sets foo to an empty string

; foo = “None” ; sets foo to the string ‘None’

; foo = ; 将foo设为空字符串

; foo = none ; 将foo设为空字符串

; foo = “none” ; 将foo设为字符串’none’

; If you use constants in your value, and these constants belong to a

; dynamically loaded extension (either a PHP extension or a Zend extension),

; you may only use these constants after the line that loads the extension.

; 如果你在指令值中使用动态扩展(PHP扩展或Zend扩展)中的常量,

; 那么你只能在加载这些动态扩展的指令行之后使用这些常量。

;;;;;;;;;;;;;;;;;;;

; About this file ;

;;;;;;;;;;;;;;;;;;;

; PHP comes packaged with two INI files. One that is recommended to be used

; in production environments and one that is recommended to be used in

; development environments.

;;;;;;;;;;;;;;;;;;;

;关于这个文件;

;;;;;;;;;;;;;;;;;;;

; 这个文件将PHP打包成两个在生产环境和推荐使用的开发环境的INI文件。

; php.ini-production contains settings which hold security, performance and

; best practices at its core. But please be aware, these settings may break

; compatibility with older or less security conscience applications. We

; recommending using the production ini in production and testing environments.

; php.ini-production包含设置,保持安全,性能和实践的核心。但请注意,这些设置可能会中断。与旧的或更少的安全应用程序兼容。推荐在生产和测试环境中使用生产INI。

; php.ini-development is very similar to its production variant, except it is

; much more verbose when it comes to errors. We recommend using the

; development version only in development environments, as errors shown to

; application users can inadvertently leak otherwise secure information.

; php.ini-development和php.ini-production非常相似,除了它发生错误时,要罗嗦得多。建议使用仅在开发环境中开发版本,如所示的错误,应用程序用户可能无意中泄漏其他安全信息。

; This is php.ini-development INI file.

; 此文档属于php.ini-development类型INI文件

;;;;;;;;;;;;;;;;;;;

; Quick Reference ;

;;;;;;;;;;;;;;;;;;;
; The following are all the settings which are different in either the production

; or development versions of the INIs with respect to PHP’s default behavior.

; Please see the actual settings later in the document for more details as to why

; we recommend these changes in PHP’s behavior.

;;;;;;;;;;;;;;;;;;;

; 快速参考 ;

;;;;;;;;;;;;;;;;;;;

; 以下是所有配置项,或对PHP的默认行为在开发版本。请参阅文档后面的实际设置,以了解更多细节。

; display_errors

; Default Value: On

; Development Value: On

; Production Value: Off

; 是否将错误信息作为输出的一部分显示。

; 在最终发布的web站点上,强烈建议你关掉这个特性,并使用错误日志代替(参看下面)。

; 在最终发布的web站点打开这个特性可能暴露一些安全信息,

; 例如你的web服务上的文件路径、数据库规划或别的信息。

; display_startup_errors

; Default Value: Off

; Development Value: On

; Production Value: Off

; 是否显示PHP启动时的错误。

; 即使display_errors指令被打开,关闭此参数也将不显示PHP启动时的错误。

; 建议你关掉这个特性,除非你必须要用于调试中。

; error_reporting

; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

; Development Value: E_ALL

; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

; 错误报告级别是位字段的叠加,推荐使用 E_ALL | E_STRICT

; 1 E_ERROR 致命的运行时错误

; 2 E_WARNING 运行时警告(非致命性错误)

; 4 E_PARSE 编译时解析错误

; 8 E_NOTICE 运行时提醒(经常是bug,也可能是有意的)

; 16 E_CORE_ERROR PHP启动时初始化过程中的致命错误

; 32 E_CORE_WARNING PHP启动时初始化过程中的警告(非致命性错)

; 64 E_COMPILE_ERROR 编译时致命性错

; 128 E_COMPILE_WARNING 编译时警告(非致命性错)

; 256 E_USER_ERROR 用户自定义的致命错误

; 512 E_USER_WARNING 用户自定义的警告(非致命性错误)

; 1024 E_USER_NOTICE 用户自定义的提醒(经常是bug,也可能是有意的)

; 2048 E_STRICT 编码标准化警告(建议如何修改以向前兼容)

; 4096 E_RECOVERABLE_ERROR 接近致命的运行时错误,若未被捕获则视同E_ERROR

; 6143 E_ALL 除E_STRICT外的所有错误(PHP6中为8191,即包含所有)

; 也可以用2147483647(所有二进制位全为1)打开现在或将来可能出现的各种错误

; html_errors

; Default Value: On

; Development Value: On

; Production value: On

; 是否在出错信息中使用HTML标记。

; 注意: 不要在发布的站点上使用这个特性!

; log_errors

; Default Value: Off

; Development Value: On

; Production Value: On

; 是否在日志文件里记录错误,具体在哪里记录取决于error_log指令。

; 强烈建议你在最终发布的web站点时使用日志记录错误而不是直接输出,

; 这样可以让你既知道那里出了问题,又不会暴露敏感信息。

; max_input_time

; Default Value: -1 (Unlimited)

; Development Value: 60 (60 seconds)

; Production Value: 60 (60 seconds)

; 每个脚本解析输入数据(POST, GET, upload)的最大允许时间(秒)。-1 表示不限制。

; output_buffering

; Default Value: Off

; Development Value: 4096

; Production Value: 4096

; 输出缓冲区大小(字节)。建议值为4096~8192。

; 输出缓冲允许你甚至在输出正文内容之后再发送HTTP头(包括cookies)。

; 其代价是输出层减慢一点点速度。

; 设置输出缓冲可以减少写入,有时还能减少网络数据包的发送。

; 这个参数的实际收益很大程度上取决于你使用的是什么Web服务器以及什么样的脚本。

; register_argc_argv

; Default Value: On

; Development Value: Off

; Production Value: Off

; 是否声明argv和argc全局变量(包含用GET方法的信息)。

; 建议不要使用这两个变量,并关掉该指令以提高性能。

; request_order

; Default Value: None

; Development Value: “GP”

; Production Value: “GP”

; 该配置项为php5.3新增指令,其默认值为’GP’

; 值 GP 表示在REQURST中默认只包含_GET和POST;这样的配置会绕过大多开源程序如dedecms、discuz中的全局变量防护;遇见上面的问题是可以将值改为′CGP′,表示_REQURST中默认只包含GET和_POST和$_COOKIE

; session.gc_divisor

; Default Value: 100

; Development Value: 1000

; Production Value: 1000

; 定义在每次初始化会话时,启动垃圾回收程序的概率。

; 这个收集概率计算公式如下:session.gc_probability/session.gc_divisor

; 对会话页面访问越频繁,概率就应当越小。建议值为1/1000~5000。

; session.hash_bits_per_character

; Default Value: 4

; Development Value: 5

; Production Value: 5

; 指定在SID字符串中的每个字符内保存多少bit,

; 这些二进制数是hash函数的运算结果。

; 4: 0-9, a-f

; 5: 0-9, a-v

; 6: 0-9, a-z, A-Z, “-”, “,”

; 建议值为 5

; short_open_tag

; Default Value: On

; Development Value: Off

; Production Value: Off

; 是否允许使用”
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php ini