佛山福山 發表於 2019-7-19 18:40:00

php-fpm配置文件详解

<h3>第一部分:FPM 配置</h3>
<div class="cnblogs_code">
<pre>-p : 命令行中动态修改--<span style="color: rgba(0, 0, 0, 1)">prefix  

;include</span>=etc/fpm.d<span style="color: rgba(0, 0, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)"><span style="color: rgba(0, 0, 0, 1)">.conf</span>  #用于包含一个或多个文件,如果glob(3)存在(glob()函数返回匹配指定模式的文件名或目录)</span></pre>
</div>
<h3>第二部分:全局配置</h3>
<p>&nbsp;由标志<span style="color: rgba(255, 102, 0, 1)"><strong></strong></span>开始:</p>
<div class="cnblogs_code">
<pre>;pid = run/php-fpm.pid        设置pid文件的位置,默认目录路径 /usr/local/php/<span style="color: rgba(0, 0, 0, 1)">var
;error_log </span>= log/php-fpm.log  记录错误日志的文件,默认目录路径 /usr/local/php/<span style="color: rgba(0, 0, 0, 1)">var
;syslog.facility </span>=<span style="color: rgba(0, 0, 0, 1)"> daemon    用于指定什么类型的程序日志消息。
;syslog.ident </span>= php-<span style="color: rgba(0, 0, 0, 1)">fpm        用于FPM多实例甄别
;log_level </span>=<span style="color: rgba(0, 0, 0, 1)"> notice          记录日志的等级,默认notice,可取值alert, error, warning, notice, debug
;emergency_restart_threshold </span>= <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">如果子进程在这个时间段内带有IGSEGV或SIGBUS退出,则重启fpm,默认0表示关闭这个功能
;emergency_restart_interval </span>= <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">  设置时间间隔来决定服务的初始化时间(默认单位:s秒),可选s秒,m分,h时,d天
;process_control_timeout </span>= <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">  子进程等待master进程对信号的回应(默认单位:s秒),可选s秒,m分,h时,d天
;process.max </span>= <span style="color: rgba(128, 0, 128, 1)">128</span><span style="color: rgba(0, 0, 0, 1)">        控制最大进程数,使用时需谨慎
;process.priority </span>= -<span style="color: rgba(128, 0, 128, 1)">19</span>     处理nice(<span style="color: rgba(128, 0, 128, 1)">2</span>)的进程优先级别-<span style="color: rgba(128, 0, 128, 1)">19</span><span style="color: rgba(0, 0, 0, 1)">(最高)到20(最低)
;rlimit_files </span>= <span style="color: rgba(128, 0, 128, 1)">1024</span><span style="color: rgba(0, 0, 0, 1)">        设置主进程文件描述符rlimit的数量
;rlimit_core </span>= <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">           设置主进程rlimit最大核数
;events.mechanism </span>=<span style="color: rgba(0, 0, 0, 1)"> epoll     使用处理event事件的机制
  ; </span>- <span style="color: rgba(0, 0, 255, 1)">select</span><span style="color: rgba(0, 0, 0, 1)">   (any POSIX os)
  ; </span>-<span style="color: rgba(0, 0, 0, 1)"> poll       (any POSIX os)
  ; </span>- epoll      (linux &gt;= <span style="color: rgba(128, 0, 128, 1)">2.5</span>.<span style="color: rgba(128, 0, 128, 1)">44</span><span style="color: rgba(0, 0, 0, 1)">)
  ; </span>- kqueue   (FreeBSD &gt;= <span style="color: rgba(128, 0, 128, 1)">4.1</span>, OpenBSD &gt;= <span style="color: rgba(128, 0, 128, 1)">2.9</span>, NetBSD &gt;= <span style="color: rgba(128, 0, 128, 1)">2.0</span><span style="color: rgba(0, 0, 0, 1)">)
  ; </span>- /dev/poll(Solaris &gt;= <span style="color: rgba(128, 0, 128, 1)">7</span><span style="color: rgba(0, 0, 0, 1)">)
  ; </span>- port       (Solaris &gt;= <span style="color: rgba(128, 0, 128, 1)">10</span><span style="color: rgba(0, 0, 0, 1)">)
;daemonize </span>=<span style="color: rgba(0, 0, 0, 1)"> yes           将fpm转至后台运行,如果设置为"no",那么fpm会运行在前台
;systemd_interval </span>= <span style="color: rgba(128, 0, 128, 1)">10</span></pre>
</div>
<h3>第三部分:进程池的定义</h3>
<p><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;通过监听不同的端口和不用管理选择可以定义多个不同的子进程池</strong>,<strong>进程池被用于记录和统计</strong>,对于fpm能够处理进程池数目的多少并没有限制</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 其中$pool变量可以在任何指令中使用,他将会替代相应的进程池名字。例如:这里的<strong></strong></p>
<div class="cnblogs_code">
<pre>   # <span style="color: rgba(0, 0, 255, 1)">ps</span> -ef | <span style="color: rgba(0, 0, 255, 1)">grep</span> php-<span style="color: rgba(0, 0, 0, 1)">fpm
    root      </span><span style="color: rgba(128, 0, 128, 1)">3028</span>   <span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">20</span>:<span style="color: rgba(128, 0, 128, 1)">33</span> ?      <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> php-fpm: master process (/usr/local/php/etc/php-<span style="color: rgba(0, 0, 0, 1)">fpm.conf)
    nobody    </span><span style="color: rgba(128, 0, 128, 1)">3029</span><span style="color: rgba(128, 0, 128, 1)">3028</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">20</span>:<span style="color: rgba(128, 0, 128, 1)">33</span> ?      <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> php-<span style="color: rgba(0, 0, 0, 1)">fpm: pool www         
    nobody    </span><span style="color: rgba(128, 0, 128, 1)">3030</span><span style="color: rgba(128, 0, 128, 1)">3028</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">20</span>:<span style="color: rgba(128, 0, 128, 1)">33</span> ?      <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> php-fpm: pool www</pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">
; It only applies on the following directives:
; </span>- <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">access.log</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
; </span>- <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">slowlog</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
; </span>- <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">listen</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)"> (unixsocket)
; </span>- <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">chroot</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
; </span>- <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">chdir</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
; </span>- <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">php_values</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
; </span>- <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">php_admin_values</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">

;prefix </span>= /path/to/pools/<span style="color: rgba(0, 0, 0, 1)">$pool    如果没有制定,将使用全局prefix替代
user </span>=<span style="color: rgba(0, 0, 0, 1)"> nobody             进程的发起用户和用户组,用户user是必须设置,group不是
group </span>=<span style="color: rgba(0, 0, 0, 1)"> nobody
listen </span>= <span style="color: rgba(128, 0, 128, 1)">127.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.1</span>:<span style="color: rgba(128, 0, 128, 1)">9000</span><span style="color: rgba(0, 0, 0, 1)">       监听ip和端口
;listen.backlog </span>= <span style="color: rgba(128, 0, 128, 1)">65535</span>       设置listen(<span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">)函数backlog
;listen.owner </span>=<span style="color: rgba(0, 0, 0, 1)"> nobody
;listen.group </span>=<span style="color: rgba(0, 0, 0, 1)"> nobody
;listen.mode </span>= <span style="color: rgba(128, 0, 128, 1)">0660</span><span style="color: rgba(0, 0, 0, 1)">
;listen.acl_users </span>=<span style="color: rgba(0, 0, 0, 1)">
;listen.acl_groups </span>=<span style="color: rgba(0, 0, 0, 1)">
;listen.allowed_clients </span>= <span style="color: rgba(128, 0, 128, 1)">127.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.1</span> 允许FastCGI客户端连接的IPv4地址,多个地址用<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">,</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">分隔,为空则允许任何地址发来链接请求
; process.priority </span>= -<span style="color: rgba(128, 0, 128, 1)">19</span><span style="color: rgba(0, 0, 0, 1)">
pm </span>=<span style="color: rgba(0, 0, 0, 1)"> dynamic             选择进程池管理器如何控制子进程的数量
  static:                     对于子进程的开启数路给定一个锁定的值(pm.max_children)
  dynamic:                   子进程的数目为动态的,它的数目基于下面的指令的值(以下为dynamic适用参数)
    pm.max_children:            同一时刻能够存活的最大子进程的数量
    pm.start_servers:         在启动时启动的子进程数量
    pm.min_spare_servers:       处于空闲</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">idle</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">状态的最小子进程,如果空闲进程数量小于这个值,那么相应的子进程会被创建
    pm.max_spare_servers:       最大空闲子进程数量,空闲子进程数量超过这个值,那么相应的子进程会被杀掉。
  ondemand:                     在启动时不会创建,只有当发起请求链接时才会创建(pm.max_children, pm.process_idle_timeout)

pm.max_children </span>= <span style="color: rgba(128, 0, 128, 1)">5</span><span style="color: rgba(0, 0, 0, 1)">
pm.start_servers </span>= <span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">
pm.min_spare_servers </span>= <span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">
pm.max_spare_servers </span>= <span style="color: rgba(128, 0, 128, 1)">3</span><span style="color: rgba(0, 0, 0, 1)">
;pm.process_idle_timeout </span>=<span style="color: rgba(0, 0, 0, 1)"> 10s;  空闲进程超时时间
;pm.max_requests </span>= <span style="color: rgba(128, 0, 128, 1)">500</span><span style="color: rgba(0, 0, 0, 1)">        在派生新的子进程前,每一个子进程应该处理的请求数目,在第三方库中解决内存溢出很有用,设置为0则不会限制
;pm.status_path </span>= /<span style="color: rgba(0, 0, 0, 1)">status      配置一个URI,以便查看fpm状态页<br>
状态页描述:
  accepted conn:               该进程池接受的请求数量
  pool:                        进程池的名字
  process manager:               进程管理,就是配置中pm指令,可以选择值static,dynamic,ondemand
  idle processes:                空闲进程数量
  active processes:            当前活跃的进程数量
  total processes:               总的进程数量</span>=idle+<span style="color: rgba(0, 0, 0, 1)">active
  max children reached:          达到最大子进程的次数,达到进程的限制,当pm试图开启更多的子进程的时候(仅当pm工作在dynamic时)
;</span><span style="color: rgba(0, 0, 255, 1)">ping</span>.path = /<span style="color: rgba(0, 0, 255, 1)">ping</span><span style="color: rgba(0, 0, 0, 1)">              该ping URI将会去调用fpm监控页面,如果这个没有设置,那么不会有URI被做为ping页
;</span><span style="color: rgba(0, 0, 255, 1)">ping</span>.response = pong            用于定制平请求的响应,响应的格式text/<span style="color: rgba(0, 0, 0, 1)">plain(对200响应代码)
;access.log </span>= log/<span style="color: rgba(0, 0, 0, 1)">$pool.access.log
;access.format </span>= <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
  ; The following syntax is allowed
  ;</span>%%: the <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">%</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)"> character
  ;</span>%C: %<span style="color: rgba(0, 0, 0, 1)">CPU used by the request
  ;      it can accept the following format:
  ;      </span>- %{user}C <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> user CPU only
  ;      </span>- %{system}C <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> system CPU only
  ;      </span>- %{total}C<span style="color: rgba(0, 0, 255, 1)">for</span> user +<span style="color: rgba(0, 0, 0, 1)"> system CPU (default)
  ;</span>%d: <span style="color: rgba(0, 0, 255, 1)">time</span><span style="color: rgba(0, 0, 0, 1)"> taken to serve the request
  ;      it can accept the following format:
  ;      </span>- %<span style="color: rgba(0, 0, 0, 1)">{seconds}d (default)
  ;      </span>- %<span style="color: rgba(0, 0, 0, 1)">{miliseconds}d
  ;      </span>- %<span style="color: rgba(0, 0, 0, 1)">{mili}d
  ;      </span>- %<span style="color: rgba(0, 0, 0, 1)">{microseconds}d
  ;      </span>- %<span style="color: rgba(0, 0, 0, 1)">{micro}d
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">e: an environment variable (same as $_ENV or $_SERVER)
  ;      it must be associated with embraces to specify the name of the </span><span style="color: rgba(0, 0, 255, 1)">env</span><span style="color: rgba(0, 0, 0, 1)">
  ;      variable. Some exemples:
  ;      </span>- server specifics like: %{REQUEST_METHOD}e or %<span style="color: rgba(0, 0, 0, 1)">{SERVER_PROTOCOL}e
  ;      </span>- HTTP headers like: %{HTTP_HOST}e or %<span style="color: rgba(0, 0, 0, 1)">{HTTP_USER_AGENT}e
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">f: script filename
  ;</span>%l: content-length of the request (<span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> POST request only)
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">m: request method
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">M: peak of memory allocated by PHP
  ;      it can accept the following format:
  ;      </span>- %<span style="color: rgba(0, 0, 0, 1)">{bytes}M (default)
  ;      </span>- %<span style="color: rgba(0, 0, 0, 1)">{kilobytes}M
  ;      </span>- %<span style="color: rgba(0, 0, 0, 1)">{kilo}M
  ;      </span>- %<span style="color: rgba(0, 0, 0, 1)">{megabytes}M
  ;      </span>- %<span style="color: rgba(0, 0, 0, 1)">{mega}M
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">n: pool name
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">o: output header
  ;      it must be associated with embraces to specify the name of the header:
  ;      </span>- %{Content-<span style="color: rgba(0, 0, 0, 1)">Type}o
  ;      </span>- %{X-Powered-<span style="color: rgba(0, 0, 0, 1)">By}o
  ;      </span>- %{Transfert-<span style="color: rgba(0, 0, 0, 1)">Encoding}o
  ;      </span>-<span style="color: rgba(0, 0, 0, 1)"> ....
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">p: PID of the child that serviced the request
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">P: PID of the parent of the child that serviced the request
  ;</span>%q: the query <span style="color: rgba(0, 0, 255, 1)">string</span><span style="color: rgba(0, 0, 0, 1)">
  ;</span>%Q: the <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">?</span><span style="color: rgba(128, 0, 0, 1)">'</span> character <span style="color: rgba(0, 0, 255, 1)">if</span> query <span style="color: rgba(0, 0, 255, 1)">string</span><span style="color: rgba(0, 0, 0, 1)"> exists
  ;</span>%r: the request URI (without the query <span style="color: rgba(0, 0, 255, 1)">string</span>, see %q and %<span style="color: rgba(0, 0, 0, 1)">Q)
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">R: remote IP address
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">s: status (response code)
  ;</span>%t: server <span style="color: rgba(0, 0, 255, 1)">time</span><span style="color: rgba(0, 0, 0, 1)"> the request was received
  ;      it can accept a strftime(</span><span style="color: rgba(128, 0, 128, 1)">3</span><span style="color: rgba(0, 0, 0, 1)">) format:
  ;      </span>%d/%b/%Y:%H:%M:%S %<span style="color: rgba(0, 0, 0, 1)">z (default)
  ;</span>%T: <span style="color: rgba(0, 0, 255, 1)">time</span><span style="color: rgba(0, 0, 0, 1)"> the log has been written (the request has finished)
  ;      it can accept a strftime(</span><span style="color: rgba(128, 0, 128, 1)">3</span><span style="color: rgba(0, 0, 0, 1)">) format:
  ;      </span>%d/%b/%Y:%H:%M:%S %<span style="color: rgba(0, 0, 0, 1)">z (default)
  ;</span>%<span style="color: rgba(0, 0, 0, 1)">u: remote user
;slowlog </span>= log/<span style="color: rgba(0, 0, 0, 1)">$pool.log.slow   用于记录慢请求
;request_slowlog_timeout </span>= <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">  慢日志请求超时时间,对一个php程序进行跟踪。
;request_terminate_timeout </span>= <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">  终止请求超时时间,在worker进程被杀掉之后,提供单个请求的超时间隔。由于某种原因不停止脚本执行时,应该使用该选项,0表示关闭不启用
  (在php.ini中,max_execution_time 一般设置为30,表示每一个脚本的最大执行时间)
;rlimit_files </span>= <span style="color: rgba(128, 0, 128, 1)">1024</span><span style="color: rgba(0, 0, 0, 1)">        设置打开文件描述符的限制
;rlimit_core </span>= <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">           设置内核对资源的使用限制,用于内核转储
;</span><span style="color: rgba(0, 0, 255, 1)">chroot</span> =<span style="color: rgba(0, 0, 0, 1)">               设置chroot路径,程序一启动就将其chroot放置到指定的目录下,该指令值必须是一个绝对路径
;chdir </span>= /var/www          在程序启动时将会改变到指定的位置(这个是相对路径,相对当前路径或chroot后的“/<span style="color: rgba(0, 0, 0, 1)">”目录)    
;catch_workers_output </span>= yes    将worker的标准输出和错误输出重定向到主要的错误日志记录中,如果没有设置,根据FastCGI的指定,将会被重定向到/dev/<span style="color: rgba(0, 0, 0, 1)">null上
;clear_env </span>=<span style="color: rgba(0, 0, 0, 1)"> no          清理环境
;security.limit_extensions </span>=<span style="color: rgba(0, 0, 0, 1)"> .php .php3 .php4 .php5  限制FPM执行解析的扩展名
;</span><span style="color: rgba(0, 0, 255, 1)">env</span> =<span style="color: rgba(0, 0, 0, 1)"> $HOSTNAME
;</span><span style="color: rgba(0, 0, 255, 1)">env</span> = /usr/local/bin:/usr/bin:/<span style="color: rgba(0, 0, 0, 1)">bin
;</span><span style="color: rgba(0, 0, 255, 1)">env</span> = /<span style="color: rgba(0, 0, 0, 1)">tmp
;</span><span style="color: rgba(0, 0, 255, 1)">env</span> = /<span style="color: rgba(0, 0, 0, 1)">tmp
;</span><span style="color: rgba(0, 0, 255, 1)">env</span> = /<span style="color: rgba(0, 0, 0, 1)">tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined </span><span style="color: rgba(0, 0, 255, 1)">in</span><span style="color: rgba(0, 0, 0, 1)"> the php.ini. The directives are the
; same as the PHP SAPI:
;   php_value</span>/php_flag             - you can set classic ini defines <span style="color: rgba(0, 0, 255, 1)">which</span><span style="color: rgba(0, 0, 0, 1)"> can
;                                    be overwritten from PHP call </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">ini_set</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">.
;   php_admin_value</span>/php_admin_flag - these directives won<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">t be overwritten by</span>
;                                     PHP call <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">ini_set</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
; For php_</span>*flag, valid values are on, off, <span style="color: rgba(128, 0, 128, 1)">1</span>, <span style="color: rgba(128, 0, 128, 1)">0</span>, <span style="color: rgba(0, 0, 255, 1)">true</span>, <span style="color: rgba(0, 0, 255, 1)">false</span><span style="color: rgba(0, 0, 0, 1)">, yes or no.

; Defining </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">extension</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)"> will load the corresponding shared extension from
; extension_dir. Defining </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">disable_functions</span><span style="color: rgba(128, 0, 0, 1)">'</span> or <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">disable_classes</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)"> will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

;php_admin_value </span>= /usr/sbin/sendmail -t -i -<span style="color: rgba(0, 0, 0, 1)">f www@my.domain.com
;php_flag </span>=<span style="color: rgba(0, 0, 0, 1)"> off
;php_admin_value </span>= /var/log/fpm-<span style="color: rgba(0, 0, 0, 1)">php.www.log
;php_admin_flag </span>=<span style="color: rgba(0, 0, 0, 1)"> on
;php_admin_value </span>= 32M</pre>
</div>
<p>&nbsp;</p>
<h3>总结:</h3>
<p>&nbsp; &nbsp; &nbsp; 在php-fpm的配置文件中,有两个指令非常重要,就是"pm.max_children" 和 "request_terminate_timeout"</p>
<p>&nbsp; &nbsp; &nbsp;  "<strong>pm.max_children</strong>" 确定了php-fpm的处理能力,原则上时越多越好,但这个是在内存足够打的前提下,每开启一个php-fpm进程要占用近30M左右的内存</p>
<p> &nbsp; &nbsp; &nbsp; 如果请求访问较多,那么可能会出现502,504错误。对于502错误来说,属于繁忙进程而造成的,对于504来说,就是客户发送的请求在限定的时间内没有得到相应,过多的请求导致“504&nbsp; Gateway&nbsp; Time-out”。这里也有可能是服务器带宽问题。</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;另外一个需要注意的指令"<strong>request_terminate_timeout</strong>",它决定php-fpm进程的连接/发送和读取的时间,如果设置过小很容易出现"502 Bad Gateway" 和 “504&nbsp; Gateway&nbsp; Time-out”,默认为0,就是说没有启用,不加限制,但是这种设置前提是你的php-fpm足够健康,这个需要根据实际情况加以限定。</p>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/mzhaox/p/11215153.html
頁: [1]
查看完整版本: php-fpm配置文件详解