【CentOS 7架构37】,设置php-fpm的pool#180109

来源:转载


hellopasswd





php-fpm的pool
vi /usr/local/php/etc/php-fpm.conf#
include = etc/php-fpm.d/*.conf
mkdir /usr/local/php/etc/php-fpm.d/
cd /usr/local/php/etc/php-fpm.d/
vi www.conf
[www]
listen=/tmp/www.sock
listen.mode=666
user=php-fpm
group=php-fpm
pm=dynamic
pm.max_children=50
pm.start_servers=20
pm.min_spare_servers=5
pm.max_spare_servers=35
pm.max_requests=500
rlimit_files=1024
[[email protected] user.com]# cd /usr/local/php-fpm/etc/
[[email protected] etc]# ls
pear.confphp-fpm.confphp-fpm.conf.defaultphp.ini
[[email protected] etc]# vi php-fpm.conf
1 [global]
2 pid = /usr/local/php-fpm/var/run/php-fpm.pid
3 error_log = /usr/local/php-fpm/var/log/php-fpm.log
4 [www]
5 listen = /tmp/php-fcgi.sock
6 listen.mode = 666
7 user = php-fpm
8 group = php-fpm
9 pm = dynamic
10 pm.max_children = 50
11 pm.start_servers = 20
12 pm.min_spare_servers = 5
13 pm.max_spare_servers = 35
14 pm.max_requests = 500
15 rlimit_files = 1024
16
17 [user.com]
18 listen = /tmp/user.sock
19 listen.mode = 666
20 user = php-fpm
21 group = php-fpm
22 pm = dynamic
23 pm.max_children = 50
24 pm.start_servers = 20
25 pm.min_spare_servers = 5
26 pm.max_spare_servers = 35
27 pm.max_requests = 500
28 rlimit_files = 1024
[[email protected] etc]# /usr/local/php-fpm/sbin/php-fpm -t
[10-Jan-2018 05:56:31] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful
[[email protected] etc]# /etc/init.d/php-fpm reload
Reload service php-fpmdone[[email protected] etc]# ps aux | grep php-fpm
root55830.30.2 2272564976 ? Ss 05:57 0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf)
php-fpm55840.00.2 2271964712 ? S05:57 0:00 php-fpm: pool www
php-fpm55850.00.2 2271964712 ? S05:57 0:00 php-fpm: pool www
php-fpm55860.00.2 2271964712 ? S05:57 0:00 php-fpm: pool www
php-fpm55870.00.2 2271964712 ? S05:57 0:00 php-fpm: pool www
php-fpm55880.00.2 2271964716 ? S05:57 0:00 php-fpm: pool www
php-fpm55890.00.2 2271964716 ? S05:57 0:00 php-fpm: pool www
php-fpm55900.00.2 2271964716 ? S05:57 0:00 php-fpm: pool www
php-fpm55910.00.2 2271964716 ? S05:57 0:00 php-fpm: pool www
php-fpm55920.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm55930.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm55940.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm55950.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm55960.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm55970.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm55980.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm55990.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm56000.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm56010.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm56020.00.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm56030.10.2 2271964720 ? S05:57 0:00 php-fpm: pool www
php-fpm56040.00.2 2271964716 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56050.00.2 2271964716 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56060.00.2 2271964716 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56070.00.2 2271964716 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56080.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56090.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56100.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56110.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56120.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56130.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56140.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56150.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56160.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56170.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56180.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56190.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56200.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56210.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56220.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
php-fpm56230.00.2 2271964724 ? S05:57 0:00 php-fpm: pool user.com
root56250.00.0 112664 980 pts/0S+ 05:58 0:00 grep --color=auto php-fpm

使用池子


[[email protected] etc]# cd /usr/local/nginx/conf/vhost/
[[email protected] vhost]# ls
aaa.com.confld.confproxy.confssl.conftest.com.conf

修改test.com.conf更换sock


或者定义一个sock


[[email protected] vhost]# vi aaa.com.conf
1 server
2 {
3listen 80 default_server;
4server_name aaa.com;
5index index.html index.htm index.php;
6root /data/wwwroot/default;
7
8location ~ /.php$
9{
10 include fastcgi_params;
11 fastcgi_pass unix:/tmp/user.sock;
12 fastcgi_index index.php;
13 fastcgi_param SCRIPT_FILEMANE /data/wwwroot/user.com$fastcgi_script_name;
14}
15
16 }

使两个域名或站点隔离开



[[email protected] vhost]# tail ../nginx.conf
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm
application/xml;
include vhost/*.conf;
}
[[email protected] vhost]# cd /usr/local/php-fpm/etc/
[[email protected] etc]# ls
pear.confphp-fpm.confphp-fpm.conf.defaultphp.ini
[[email protected] etc]# vi php-fpm.conf
1 [global]
2 pid = /usr/local/php-fpm/var/run/php-fpm.pid
3 error_log = /usr/local/php-fpm/var/log/php-fpm.log
4 include = etc/php-fpm.d/*.confs
[[email protected] etc]# mkdir php-fpm.d
[[email protected] etc]# cd php-fpm.d/
[[email protected] php-fpm.d]# vi www.conf
1 [www]
2 listen = /tmp/php-fcgi.sock
3 listen.mode = 666
4 user = php-fpm
5 group = php-fpm
6 pm = dynamic
7 pm.max_children = 50
8 pm.start_servers = 20
9 pm.min_spare_servers = 5
10 pm.max_spare_servers = 35
11 pm.max_requests = 500
12 rlimit_files = 1024
[[email protected] php-fpm.d]# vi user.conf
1 [user.com]
2 listen = /tmp/user.sock
3 listen.mode = 666
4 user = php-fpm
5 group = php-fpm
6 pm = dynamic
7 pm.max_children = 50
8 pm.start_servers = 20
9 pm.min_spare_servers = 5
10 pm.max_spare_servers = 35
11 pm.max_requests = 500
12 rlimit_files = 1024
[[email protected] php-fpm.d]# /usr/local/php-fpm/sbin/php-fpm -t
[10-Jan-2018 06:11:36] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful
[[email protected] php-fpm.d]# /etc/init.d/php-fpm reload
Reload service php-fpmdone
[[email protected] php-fpm.d]# ps aux | grep php-fpm
root57130.10.2 2272844980 ? Ss 06:12 0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf)
php-fpm57140.00.2 2272244716 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57150.00.2 2272244716 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57160.00.2 2272244716 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57170.00.2 2272244716 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57180.00.2 2272244720 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57190.00.2 2272244720 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57200.00.2 2272244720 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57210.00.2 2272244720 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57220.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57230.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57240.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57250.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57260.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57270.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57280.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57290.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57300.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57310.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57320.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57330.00.2 2272244724 ? S06:12 0:00 php-fpm: pool user.com
php-fpm57340.00.2 2272244720 ? S06:12 0:00 php-fpm: pool www
php-fpm57350.00.2 2272244720 ? S06:12 0:00 php-fpm: pool www
php-fpm57360.00.2 2272244720 ? S06:12 0:00 php-fpm: pool www
php-fpm57370.00.2 2272244720 ? S06:12 0:00 php-fpm: pool www
php-fpm57380.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57390.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57400.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57410.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57420.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57430.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57440.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57450.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57460.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57470.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57480.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57490.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57500.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57510.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57520.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
php-fpm57530.00.2 2272244728 ? S06:12 0:00 php-fpm: pool www
root57550.00.0 112664 980 pts/0S+ 06:12 0:00 grep --color=auto php-fpm

效果一样的




“Unix domain socket (/tmp/www.sock)或者 IPCsocket (127.0.0.1:9000)是一种终端,可以使同一台操作系统上的两个或多个进程进行数据通信。与管道相比,Unix domain sockets 既可以使用字节流数和数据队列,而管道通信则只能通过字节流。Unix domain sockets的接口和Internet socket很像,但它不使用网络底层协议来通信。Unix domain socket 的功能是POSIX操作系统里的一种组件。 Unix domain sockets 使用系统文件的地址来作为自己的身份。它可以被系统进程引用。所以两个进程可以同时打开一个Unix domain sockets来进行通信。不过这种通信方式是发生在系统内核里而不会在网络里传播。
即:nginx 和 php 利用 这个socket 进行通信





修改于 180109

分享给朋友:
您可能感兴趣的文章:
随机阅读: