php-fpm配置多进程池
发表于:2019-07-31 15:06:28浏览:84次
### php配置文件的进程池引用代码查看
```bash
sudo vim /etc/php5/fpm/php-fpm.conf
```
找到 `Pool Definitions`
```bash
;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;
; Multiple pools of child processes may be started with different listening
; ports and different management options. The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)
; To configure the pools it is recommended to have one .conf file per
; pool in the following directory:
include=/etc/php5/fpm/pool.d/*.conf
```
最后一句可以看到 进程池的 引入代码`include=/etc/php5/fpm/pool.d/*.conf`
### 配置 多进程池
```bash
cd /etc/php5/fpm/pool.d/
sudo cp www.conf 9001.conf
sudo vim 9001.conf
```
修改如下内容
```bash
[www] -> [www-9001] # 修改 进程池名称
listen = 127.0.0.1:9000 -> listen = 127.0.0.1:9001 # 修改 监听端口
```
### 重启服务
```bash
sudo service php5-fpm restart
```
### nginx 配置
```bash
cd /etc/nginx
sudo mkdir confi.d
sudo vim upstream.conf
```
写入如下内容
```bash
upstream php5-fpm-9000-1 {
server 127.0.0.1:9000 max_fails=3 fail_timeout=5s;
server 127.0.0.1:9001 max_fails=3 fail_timeout=5s;
}
```
将配置添加到nginx
```bash
sudo vim /etc/nginx/nginx.conf
```
加入配置代码 `include conf.d/*.conf;`
```bash
http {
....
include conf.d/*.conf;
..
include /etc/nginx/sites-enabled/*;
}
```

