Linux平台PHP5.4如何设置FPM线程数量

发布时间:2021-08-26 09:37:18 作者:小新
来源:亿速云 阅读:219

这篇文章主要介绍Linux平台PHP5.4如何设置FPM线程数量,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

具体如下:

PHP5.4安装完毕后,FPM的默认配置文件位于/usr/local/php/etc/php-fpm.conf.default

>cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
>vim /usr/local/php/etc/php-fpm.conf

输入”/www”,搜索www所在的POOL

pm = dynamic
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 5
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 2
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 1
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500

解释一下:

pm = dynamic 如何控制子进程,选项有static和dynamic,默认采用dynamic;如果选择static,则由pm.max_children指定固定的子进程数。

如果选择dynamic,则由以下参数决定:

pm.max_children子进程最大数
pm.start_servers启动时的进程数
pm.min_spare_servers保证空闲进程数最小值,如果空闲进程小于此值,则创建新的子进程
pm.max_spare_servers保证空闲进程数最大值,如果空闲进程大于此值,则进行清理。对于专用服务器,pm可以设置为static。
pm.max_requests设置每个子进程重生之前服务的请求数. 对于可能存在内存泄漏的第三方模块来说是非常有用的. 如果设置为 '0′ 则一直接受请求. 设置为500就可以了(默认0)。

将值修改为如下:

pm.max_children = 32
pm.start_servers = 16
pm.min_spare_servers = 8
pm.max_spare_servers = 32
pm.max_requests = 500

:wq 保存退出VIM

>/usr/local/php/sbin/php-fpm -t
NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful

测试配置文件是否正常,没问题,杀掉当前的FPM进程

>/usr/local/php/sbin/php-fpm

启动

以上是“Linux平台PHP5.4如何设置FPM线程数量”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. php5.4中的php-fpm命令
  2. linux中php5.4安装的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux php5.4 fpm

上一篇:Linux中怎么通过kill命令杀死指定进程

下一篇:linux实现定时任务命令有哪些

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》