Live2D

Prometheus php-fpm监控安装部署

1.进入默认php配置文件:/etc/php/7.3/fpm/php-fpm.conf 添加:pm.status_path = /fpm_status

echo "pm.status_path = /fpm_status" >>/etc/php/7.3/fpm/php-fpm.conf 

2.在nginx配置文件下面添加fpm-status location配置:/etc/nginx/conf.d/nginx-php.conf

    location ~ ^/(fpm_status|health)$ {
        fastcgi_pass unix:/run/php/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

systemctl restart php7.3-fpm

systemctl reload nginx

测试一下:curl http://localhost:9090/fpm_status 有数据就ok

安装这个文件: php-fpm-exporter.linux.amd64 (官网地址:https://github.com/bakins/php-fpm-exporter/releases)

安装好了 :

mkdir /usr/local/php-fpm-exporter/
scp root123@172.0.100.1:~/php-fpm-exporter /usr/local/php-fpm-exporter/
cd /usr/local/php-fpm-exporter/
chmod +x  php-fpm-exporter
nohup ./php-fpm-exporter --addr="172.0.100.49:9190" --endpoint="http://172.0.100.49:9090/fpm_status" >nohup.out 2>&1 &

netstat -ntpl |grep 

测试:curl 172.0.100.49:9190/metrics(也可以不用测试)

nohup /usr/local/php-fpm-exporter/php-fpm-exporter --addr="`ip a|grep global|awk -F'[ ]+|/' '{print $3}'`:9190" --endpoint="http://`ip a|grep global|awk -F'[ ]+|/' '{print \$3}'`:9090/fpm_status" >/usr/local/php-fpm-exporter/nohup.out 2>&1 &
server {
    listen       9090 backlog=8192;
    server_name  172.0.100.33;
    root   /data/qcnft_php/public;
    access_log  /data/log/nginx/qcsc_access.log  log_json;
    error_log /data/log/nginx/qcsc_error.log;

    keepalive_timeout 60s;
    
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";
    
    index index.html index.htm index.php;
    
    charset utf-8;
    
    location / {
        try_files $uri $uri/ /index.php?$query_string; 
    }
      
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    
    error_page 404 /index.php;
    
    location ~ /\.(?!well-known).* {
        deny all;
    }
    
    location = /nginx_status {
    	stub_status on;
    access_log off;
    }


    location ~ \.php$ {
        fastcgi_pass   unix:/run/php/php-fpm.sock;
        fastcgi_index  index.php;
    fastcgi_read_timeout 150;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    location ~ /\.(?!well-known).* {
        deny all;
    }
    location ~ ^/(fpm_status|health)$ {
        fastcgi_pass unix:/run/php/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

}
posted @   mend。  阅读(91)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示