Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx Monitoring and lnmp Architecture

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

System-level monitoring

Top

Ps

Netstat

Ss

Journal

Configure Nginx status information

Add compilation parameter-- with-http_stub_status_module

Add stub_status on to the configuration file

Https://coding.net/u/aminglinux/p/nginx/git/blob/master/mon/stat.md

Configure Nginx statu

Nginx has a built-in status page, which needs to be opened by specifying the parameter with-http_stub_status_module at compile time.

That is, this function is provided by the http_stub_status_module module and is not loaded by default.

Nginx profile exampl

Server {

Listen 80

Server_name www.aminglinux.com

Location / status/ {stub_status on; access_log off; allow 127.0.0.1; allow 192.168.10.Universe 24; deny all;}

}

Configuration description

Location / status/ so that the content of the status page can be accessed when / status/ is accessed. Stub_status on opens the status page. Access_log off does not log allow and deny can only be accessed by specified IP and IP segments, because this page needs to be protected, is not public, and of course can be used for user authentication.

Test and result description

Test command: curl-x127.0.0.1 purl 80 www.aminglinux.com/status/

The results are as follows:

Active connections: 1

Server accepts handled requests

11 11 11

Reading: 0 Writing: 1 Waiting: 0

Description:

Active connections-number of active connections

Server accepts handled requests-Total number of connections processed, handshakes successfully created, total number of requests processed

It should be noted that a connection can have multiple requests.

Reading-reads the number of connections from the client.

Writing-number of response data to the client

Waiting-when keep-alive is enabled, this value equals active-(reading+writing), which means that Nginx has finished processing the resident connection waiting for the next request instruction.

Nginx surveillance. We use it to zabbix.

The monitoring chart is as follows

Nginx Architecture-LNMP

Php-fpm exists as a separate service

Nginx handles static files directly

Nginx will send php's request to php-fpm through proxy.

LNMP architecture building

Install MySQL/Mariadb

Install php-fpm

Install Nginx

Reference http://www.apelearn.com/study_v2/chapter18.html

Configure Nginx and php

Https://coding.net/u/aminglinux/p/nginx/git/blob/master/lnmp/nginx_php.md

Configure Nginx and php

The configuration is as follows (added in server section):

Location ~ .php ${

Include fastcgi_params

Fastcgi_pass unix:/tmp/php-fcgi.sock

Fastcgi_index index.php

Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name

}

Configuration instructions:

1 the fastcgi_params file is under / usr/local/nginx/conf/, and its contents are fastcgi-related variables

2 fastcgi_pass is followed by the php-fpm service listening address, which can be IP:PORT, unix socket address, or upstream address

3 fastcgi_index defines the index page. If index parameters are defined in other parts of the server, this configuration can be ignored.

The line 4 fastcgi_param can actually define the SCRIPT_FILENAME variable in the fastcgi_params file. If this variable is not defined, the php request cannot be accessed.

My monitoring is based on lnmp architecture. You can check the installation process of zabbix.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report