Home >Operation and Maintenance >Nginx >How to configure Nginx to detect service status
1. Check whether the check status module is installed;
[root@localhost ~]# nginx -v nginx version: nginx/1.12.2 built by gcc 4.8.5 20150623 (red hat 4.8.5-36) (gcc) configure arguments: --prefix=/usr/local/nginx --with-http_sub_module
2. If it is not installed, recompile and install;
ø Check Status module; --with-http_stub_status_module
[root@localhost ~]# cd /usr/local/src/nginx-1.12.2/ [root@localhost ~]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module [root@localhost ~]# make && make install
3. Edit nginx configuration file;
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf server { listen 80; server_name localhost; #access_log logs/host.access.log main; location /nginx_status { stub_status on; access_log off; #allow 127.0.0.1; ##可对该页面的访问者进行过滤 #deny all; } } [root@localhost ~]# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful [root@localhost ~]# nginx -s reload
4. Test syntax;
[root@localhost ~]# curl http://192.168.10.110:80/nginx_status active connections: 1 server accepts handled requests 1 1 1 reading: 0 writing: 1 waiting: 0
5. Detailed explanation of the output content;
First line active connections: 1 ——The number of active connections, including waiting Number of clients 0 |
The second line server accepts handled requests——A total of 1 connection was processed, 1 handshake was successfully created, and a total of 1 request was processed |
The third line reading - reading the number of connections from the client, writing - the number of response data to the client, waiting - when keep-alive is turned on, this value is equal to active - (reading writing), which means nginx has After processing the resident connection that is waiting for the next request command. |
The above is the detailed content of How to configure Nginx to detect service status. For more information, please follow other related articles on the PHP Chinese website!