基本配置

系统为ubuntu,在usr/etc/sites-enabled/中编辑nginx配置文件

server_name demo.com;
location ~^/status$ {
        #auth_basic "status page";
        #fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        #如果是端口请用 fastcgi_pass 127.0.0.1:9000;
    }

status配置

另外需要在/etc/php5/fpm/pool.d/www.conf中修改一项,把status打开

pm.status_path = /status

当然可以看看fpm中关于staus的一些参数说明。
然后重启fpm 和nginx
servie php5-fpm start|status|stop
service nginx relaod

成功

成功后可以看到如下图
图片描述

更简单一点

root@php56:/home/tb# /etc/init.d/php5.6-fpm status
● php5.6-fpm.service - The PHP 5.6 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php5.6-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-11-05 15:10:30 CST; 1 weeks 0 days ago
     Docs: man:php-fpm5.6(8)
 Main PID: 1224 (php-fpm5.6)
   Status: "Processes active: 1, idle: 2, Requests: 386, slow: 0, Traffic: 0req/sec"
    Tasks: 4
   Memory: 73.1M
      CPU: 37.991s
   CGroup: /system.slice/php5.6-fpm.service
           ├─ 1224 php-fpm: master process (/etc/php/5.6/fpm/php-fpm.conf)
           ├─ 1418 php-fpm: pool www
           ├─ 2492 php-fpm: pool www
           └─12915 php-fpm: pool www

enable-monitor-php-fpm-status-in-nginx

扩展:fpm三种配置参数相关说明

static  - a fixed number (pm.max_children) of child processes;

dynamic - the number of child processes are set dynamically based on the
          following directives. With this process management, there will be
          always at least 1 children.
             pm.max_children      - the maximum number of children that can
                                    be alive at the same time.
             pm.start_servers     - the number of children created on startup.
             pm.min_spare_servers - the minimum number of children in 'idle'
                                    state (waiting to process). If the number
                                    of 'idle' processes is less than this
                                    number then some children will be created.
             pm.max_spare_servers - the maximum number of children in 'idle'
                                    state (waiting to process). If the number
                                    of 'idle' processes is greater than this
                                    number then some children will be killed.
                                    
 ondemand - no children are created at startup. Children will be forked when
             new requests will connect. The following parameter are used:
             pm.max_children           - the maximum number of children that
                                         can be alive at the same time.
             pm.process_idle_timeout   - The number of seconds after which
                                         an idle process will be killed.

牙小木木
1.5k 声望80 粉丝

iamtb.cn


引用和评论

0 条评论