实验环境:CentOS7

[root@~ localhost]#yum -y install php-fpm
php-fpm包:用于将php运行于fpm模式
#在安装php-fpm时,一般同时安装如下包
[root@~ localhost]#yum -y install php-mbstring php-mcrypt php-mysql
[root@~ localhost]#rpm -ql php-fpm
/etc/logrotate.d/php-fpm
/etc/php-fpm.conf #服务配置文件
/etc/php-fpm.d
/etc/php-fpm.d/www.conf #主配置文件

/etc/sysconfig/php-fpm
/run/php-fpm
/usr/lib/systemd/system/php-fpm.service
/usr/lib/tmpfiles.d/php-fpm.conf
/usr/sbin/php-fpm
/usr/share/doc/php-fpm-5.4.16
/usr/share/doc/php-fpm-5.4.16/fpm_LICENSE
/usr/share/doc/php-fpm-5.4.16/php-fpm.conf.default
/usr/share/fpm
/usr/share/fpm/status.html #内置的网页状态测试页面
/usr/share/man/man8/php-fpm.8.gz
/var/log/php-fpm
[root@~ localhost]#vi /etc/php-fpm.conf ;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;
; Global Options ;  #全局配置选项
;;;;;;;;;;;;;;;;;; [global]
; Pid file
; Default Value: none
pid = /run/php-fpm/php-fpm.pid    #内存中的进程编号文件 ; Error log file
; Default Value: /var/log/php-fpm.log
error_log = /var/log/php-fpm/error.log    #错误日志文件 ; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice              #定义日志级别 ; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
daemonize = no          #是否以守护进程的方式运行,no表示不是 ;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;        #定义连接池,对应的文件是:/etc/php.-fpm.d/www.conf
;;;;;;;;;;;;;;;;;;;; ; See /etc/php-fpm.d/*.conf
#fpm模式监听的端口是9000
[root@php-fpm.d localhost]#cp -av www.conf{,.bak} #修改配置文件时先备份
‘www.conf’ -> ‘www.conf.bak’
[root@php-fpm.d localhost]#vi www.conf ; Start a new pool named 'www'.
[www]
; Note: This value is mandatory.
listen = 127.0.0.1:9000    #监听本地的ip和端口; ; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: -1

;listen.backlog = -1      #后援队列:当请求数大于并发数时,设置排队等待的请求数;-1表示无限制

listen.allowed_clients = 127.0.0.1  #授权设置,允许那些主机可以连接本服务主机;若httpd在别的主机,则需要修改

user = apache        #运行进程的用户
; RPM: Keep a group allowed to write in log dir.
group = apache        #运行进程的组

#运行子进程的方式:static 静态方式 和dynamic 动态方式

; 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
; following directives:
; pm.max_children - the maximum number of children that can
; number then some children will be killed.
; Note: This value is mandatory.
pm = dynamic  #以动态方式运行

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; 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.
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
pm.max_children = 50    #最大子进程数

; 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 = 5    #服务启动,先创建的服务数量

; 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 = 5  #启动的最小空闲服务数量,应大于启动时创建的服务数

; 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 = 35  #启动的最大空闲服务数量

; 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  #每个子进程最多响应多少个请求,然后关闭

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
; accepted conn - the number of request accepted by the pool;
; pool - the name of the pool;
; may conflict with a real PHP file.
; Default Value: not set
pm.status_path = /pmstatus  #启用此行,内置状态页,改成pmstatus

; may conflict with a real PHP file.
; Default Value: not set
ping.path = /ping    #服务器远程健康状况探测,检测服务器是否正常

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
ping.response = pong  #探测回应

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0  #响应超时时间,0表示不超时

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)

; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can

pm.min_spare_servers = 5

; 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 = 35

; 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

php_value[session.save_handler] = files

php_value[session.save_path] = /var/lib/php/session  

#服务器端保存的会话的路径,默认没有创建,需手动创建,并将属主和属组修改修改成此进程的属主和属组,即apache:apache

"www.conf" 226L, 10018C

[root@php-fpm.d localhost]#mkdir -pv /var/lib/php/session  #创建会话的文件
[root@php-fpm.d localhost]#chown apache:apache /var/lib/php/session  #修改文件的属组属组为apache:apache
[root@php-fpm.d localhost]#systemctl start php-fpm.service  #启动php-fpm服务
[root@php-fpm.d localhost]#ss -ntl |grep "9000"        #检查9000端口是否启动
LISTEN 0 128 127.0.0.1:9000 *:*
[root@php-fpm.d localhost]#ps aux | grep "php-fpm"      #检查主进程和子进程是否按照配置生成
root 43438 0.8 1.1 330704 10440 ? Ss 13:05 0:00 php-fpm: master process (/etc/php-fpm.conf)
apache 43440 0.0 0.5 332788 5060 ? S 13:05 0:00 php-fpm: pool www
apache 43441 0.0 0.5 332788 5060 ? S 13:05 0:00 php-fpm: pool www
apache 43442 0.0 0.5 332788 5060 ? S 13:05 0:00 php-fpm: pool www
apache 43443 0.0 0.5 332788 5060 ? S 13:05 0:00 php-fpm: pool www
apache 43444 0.0 0.5 332788 5060 ? S 13:05 0:00 php-fpm: pool www
root 43465 0.0 0.1 112648 964 pts/5 S+ 13:07 0:00 grep --color=auto php-fpm
 

https://www.cnblogs.com/wzhuo/p/6936999.html

PHP-FPM包的安装与配置 转的更多相关文章

  1. php-fpm包的安装与配置

    实验环境:CentOS7 [root@~ localhost]#yum -y install php-fpm php-fpm包:用于将php运行于fpm模式 #在安装php-fpm时,一般同时安装如下 ...

  2. mysql源码包手动安装、配置以及测试(亲测可行)

    笔记编者:小波/qq463431476博客首页:http://www.cnblogs.com/xiaobo-Linux/ 记下这篇mysql笔记,望日后有用! redhat6采用centos yum源 ...

  3. Charles抓包工具安装与配置

    在实际开发中,我们需要时常抓取线上的请求及数据,甚至是请求的html文档,js,css等静态文件来进行调试.在这里,我使用charles来进行以上操作.但是呢,charles需要进行一系列配置才能达到 ...

  4. mysql二进制包安装与配置实战记录

    导读 一般中小型网站的开发都选择 MySQL 作为网站数据库,由于其社区版的性能卓越,搭配 PHP .Linux和 Apache 可组成良好的开发环境,经过多年的web技术发展,在业内被广泛使用的一种 ...

  5. zabbix安装及配置(rpm包安装mysql,php,apache,zabbix)

    zabbix安装及配置 一.安装mysql.php.apache.zabbix 安装环境: 操作系统:rhel6.3-x86-64  mysql:5.6.23   --官网下载rpm包安装php:5. ...

  6. 使用RPM包安装、配置和拆卸MySQL

    通过rpm包安装.配置及卸载mysql的详细过程. 以MySQL-server-4.0.14-0.i386.rpm为例,放在/usr/src目录下 cd /usr/src rpm -ivh MySQL ...

  7. Linux_CentOS软件安装调试 源代码包编译安装和 二进制包配置

    Linux 下源代码(C 语言)如何编译(安装) 1. 先安装源代码编译的软件 gcc,make,openssl 如下: yum install -y gcc make gcc-c++ openssl ...

  8. 抓包工具fiddler下载配置(一):下载/安装&信任证书

    简介 Fiddler一个http协议调试代理工具,它能够记录并检查所有你的电脑和互联网之间的http通讯,设置断点,查看所有的“进出”Fiddler的数据(指cookie,html,js,css等文件 ...

  9. linux的软件管理的rpm包和yum配置加tar解压包和安装编译./configuer

    软件管理 rpm包  和yum 1.软件形式 Linux系统的第三方软件,无论是应用软件还是工具软件,大多以以下两种形式之一发行: 源代码形式       预编译形式 获取的源代码形式的软件,需要对其 ...

随机推荐

  1. Traveling by Stagecoach(POJ 2686)

    原题如下: Traveling by Stagecoach Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4494   Ac ...

  2. [Java并发编程之美]第1章 线程基础 补充知识

    1.2线程创建与运行 创建线程有三种方式: 继承Thread类并重写run方法: 实现Runnable接口的run方法,new Thread时将该类对象作为参数传入: 实现Callable接口的cal ...

  3. JavaScript中常用的数据输出方式解析

    在js中,一般使用如下几种方式进行数据的输出: 1. 在浏览器的控制台输出 浏览器F12打开浏览器控制台(一般前端开发人员必备浏览器为谷歌浏览器,下面就以谷歌浏览器为例对控制台尽心解析): 1.1 E ...

  4. linux学习(四)Linux 文件基本属性

    一.引言 Linux系统是一种典型的多用户系统,不同的用户处于不同的地位,拥有不同的权限. 为了保护系统的安全性,Linux系统对不同的用户访问同一文件(包括目录文件)的权限做了不同的规定. 在Lin ...

  5. dubbo学习(八)dubbo项目搭建--消费者(服务消费者)

    PS:  项目架子以及工程间的maven依赖配置暂时省略,后续看情况可能会单独写一篇文章捋捋框架结构,先马克~ 配置和启动 1.pom文件引入dubbo和zookeeper的操作客户端(此步骤与生产者 ...

  6. 使用eclipse启动tomcat,正常模式下可以启动tomcat,却在debug模式下无法启动tomcat 问题解决

    这个问题可能是由于eclipse和tomcat的交互而产生的,在以debug模式启动tomcat时,发生了读取文件错误,eclipse自动设置了断点,导致tomcat不能正常启动. 解决方法把brea ...

  7. Spring Boot 自动配置的原理、核心注解以及利用自动配置实现了自定义 Starter 组件

    本章内容 自定义属性快速入门 外化配置 自动配置 自定义创建 Starter 组件 摘录:读书是读完这些文字还要好好用心去想想,写书也一样,做任何事也一样 图 2 第二章目录结构图 第 2 章 Spr ...

  8. 使用内置对象Math.random实现猜数字游戏

    function getRandom(min,max){ return Math.floor(Math.random()*(max-min+1))+min;    //得到两个数之间的随机整数,包含实 ...

  9. PyCharm-缩进 格式化代码

    格式化代码 Ctrl + Alt + l 缩进代码 Tab    向右缩进4格 Shift + Tab 向左缩进4格

  10. Centos-内核核心组成

    linux内核,相当于linux大脑,高可靠和高稳定都是针对内核来说 完整linux核心组成部分 1. 内存管理 合理有效的管理整个系统的物理内存,同时快速响应内核各子系统对内存分配的请求 2. 进程 ...