PHP-FPM 的工作整理

Posted 王小麦

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP-FPM 的工作整理相关的知识,希望对你有一定的参考价值。

1.php-fpm的配置文件

根据命令找到路径修改配置文件

ps -ef|grep php-fpm

vim /home/php/etc/php-fpm.conf

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
pid = run/php-fpm.pid
error_log = log/error.log

daemonize = yes
log_level = warning

;syslog.facility = daemon
;syslog.ident = php-fpm

; golbal max fork process
process.max = 100

;child reuse timeout
process_control_timeout = 10s

;emergency_restart_threshold = 0
;emergency_restart_interval = 60s

;process.priority = -19
;rlimit_files = 1024
;rlimit_core = 0
;systemd_interval = 10

; Specify the event mechanism FPM will use. The following is available:
; - select     (any POSIX os)
; - poll       (any POSIX os)
; - epoll      (linux >= 2.5.44)
; - kqueue     (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll  (Solaris >= 7)
; - port       (Solaris >= 10)
; Default Value: not set (auto detection)
events.mechanism = epoll

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ; 
;;;;;;;;;;;;;;;;;;;;

[oracle]

prefix = /home/php
user   = oracle
group  = dba

;listen.owner = oracle
;listen.group = dba
;listen.mode = 0660

;listen = 127.0.0.1:9000
listen = /tmp/php-cgi.sock
listen.backlog = 2048 

; Default Value: any
listen.allowed_clients = 127.0.0.1

; Choose how the process manager will control the number of child processes. Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
;   dynamic - the number of child processes are set dynamically based on the
;  ondemand - no children are created at startup. Children will be forked when
pm = dynamic

;pm is `static` only
pm.max_children = 100

pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 20

;pm.status_path = /status

pm.max_requests = 3000
pm.process_idle_timeout = 300s

;php max_block timeout
request_terminate_timeout = 120s

rlimit_files = 10240
catch_workers_output = yes

;access.log = var/log/access.log
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"

;slowlog = var/log/slow.log
;request_slowlog_timeout = 300s
  
;chroot = 
;chdir = /var/www
;ping.path = /ping
;ping.response = pong
 
;Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5
 
;Default Value: clean env
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin:/home/php/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

php_admin_value[memory_limit] = 256M

;php_flag[display_errors] = off
;php_admin_flag[log_errors] = on
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]

 

2.php.ini的配置

extension_dir = /home/php/lib/php/extensions/no-debug-zts-20121212
extension = phalcon.so
extension = memcache.so
extension = mongo.so
extension = xwebxsvc.so
extension = imagick.so
extension = mysqli.so
;;zend_extension = opcache.so
;;extension = xwebphp.so

[xwebxsvc]
xwebxsvc.UdpMultiIp = 239.0.1.1
xwebxsvc.UdpMultiPort = 0
xwebxsvc.LocalWeight = 8
xwebxsvc.RemoteServices = 

cgi.fix_pathinfo = 1
memory_limit = 128M

;***** Added by go-pear
include_path="/home/php:"
;*****

auto_append_file = None
allow_url_fopen = On
file_uploads = On
upload_tmp_dir = /tmp/uploads
upload_max_filesize = 50M
post_max_size = 50M
max_input_time = 300
max_execution_time = 300
date.timezone = PRC

[opcache]
opcache.enable=1
opcache.enable_cli=0
opcache.fast_shutdown=0
;;16M
opcache.memory_consumption=16
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60

[session]
;;use memcached-1.0.5
;;handler => files("/tmp/sess") or memcached("localhost:11210")
;;session.save_handler = memcached
;;session.save_path = "localhost:11210"

session.save_handler = memcache
session.save_path = "tcp://localhost:11210;tcp://localhost:11211;tcp://localhost:11212"

;;session.auto_start = 1
;;480==8hours
session.cache_expire = 480
session.use_cookies = 1

;;use memcached: set cookie_path null!
session.cookie_path = /
;;gc_maxlifetime=>8hours
session.cookie_lifetime = 28800
session.gc_maxlifetime = 28800
session.gc_probability = 1
session.gc_divisor = 100
session.use_only_cookies = 1
session.use_trans_sid = 1

[mysqli]
mysqli.default_socket = /opt/zbox/tmp/mysql/mysql.sock

 

以上是关于PHP-FPM 的工作整理的主要内容,如果未能解决你的问题,请参考以下文章

sublimetext3中保存代码片段

VS2015 代码片段整理

小程序各种功能代码片段整理---持续更新

常用python日期日志获取内容循环的代码片段

docker 构建php-fpm IMages(dockerfile)

最全最详细publiccms常用的代码片段