nginx 增加监控状态:
vim /usr/local/nginx/conf/nginx.conf
location /nginx-status{
stub_status on; //所有的访问,都会被记录在访问日志里
# allow 192.168.0.0/16;
#deny all;
access_log off;
}
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
# fastcgi_pass unix:/var/run/php-fpm.sock;
检查nginx的语法:
/usr/local/nginx/sbin/nginx -t
重起nginx服务:
systemctl reload nginx
浏览器访问测试:
192.168.1.20/nginx-status
这里写代码片
Active connections: 3
server accepts handled requests
10 10 4
Reading: 0 Writing: 1 Waiting: 2
`
php-fpm的状态检测:
vim /usr/local/php/etc/php-fpm.d/www.conf
pm.status_path = /status //把这一行的注释打开
重器php-fpm服务:
systemctl restart php-fpm
浏览器访问测试:
192.168.1.20/status //返回是404的报错的页面
原因在于 /status 转换不了给nginx的php处理;
查看一下nginx的配置文件的正则表达:
location ~ \.php$ {
root html;
只有以php结尾的才可以交给nginx处理
把php-fpm服务修改:
vim /usr/local/php/etc/php-fpm.d/www.conf
pm.status_path = /status .php //把这一行的注释打开
重起php-fpm服务:
[root@pxe ~]# systemctl restart php-fpm
浏览器访问:
http://192.168.1.20/status.php
pool: www
process manager: ondemand
start time: 04/Sep/2018:15:01:35 +0800
start since: 9
accepted conn: 1
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 0
active processes: 1
total processes: 1
max active processes: 1
max children reached: 0
slow requests: 0
[root@apache conf.d]# pwd
/etc/httpd/conf.d
vim info.conf
这里写代码片