1コア構成
-
ワーカープロセスのユーザーの設定は、Linuxのユーザーを指します。これには、nginxがディレクトリまたはファイルを操作するためのいくつかの権限が含まれます。デフォルトは
nobody
user root;
-
ワーカープロセスの数を設定します。一般的に、CPUが少ない場合は、数を設定するか、N-1に設定します。
worker_processes 1;
-
nginxログレベルのデバッグ|情報|通知|警告|エラー|クリティカル|アラート| emerg、エラーレベルは左から右に増加します
-
nginxプロセスpidを設定します
pid logs/nginx.pid;
-
作業モードを設定する
events { # 默认使用epoll use epoll; # 每个worker允许连接的客户端最大连接数 worker_connections 10240; }
-
httpはコマンドブロックであり、httpネットワーク送信用のいくつかのコマンド構成です。
http { }
-
includeは、読みやすさを向上させ、単一の構成ファイルが大きすぎないようにするための外部構成を導入します
include mime.types;
-
変数を直接使用できる
main
ように、形式で定義された名前であるログ形式を設定しますaccess_log
パラメータ名 パラメータの意味 $ remote_addr クライアントIP $ remote_user リモートクライアントのユーザー名、通常: '-' $ time_local 時間とタイムゾーン $ request 要求されたURLとメソッド $ status 応答ステータスコード $ body_bytes_send 応答クライアントコンテンツバイト $ http_referer ユーザーがジャンプしたリンクを記録する $ http_user_agent ユーザーが使用するプロキシは通常、ブラウザから取得されます $ http_x_forwarded_for プロキシサーバーを介してクライアントのIPを記録します -
sendfile
効率的なファイル転送を使用して、転送パフォーマンスを向上させます。有効tcp_nopush
にした後でのみ使用できます。つまり、データテーブルは、特定のサイズが蓄積された後にのみ送信されるため、効率が向上します。sendfile on; tcp_nopush on;
-
keepalive_timeoutは、クライアントとサーバーの要求のタイムアウト時間を設定して、クライアントが複数回要求したときに新しい接続が繰り返し確立されないようにし、リソースの消費を節約します。
#keepalive_timeout 0; keepalive_timeout 65;
2一般的なコマンド
2.1停止
1暴力をやめる(不推荐
)
[root@localhost ~]# /usr/local/nginx/sbin
[root@localhost sbin]# ./nginx -s stop
2リクエストが終了するのを待ってから、閉じます(httpの場合のみ推荐
)
[root@localhost sbin]# ./nginx -s quit
2.2構成ファイルを確認する
[root@localhost sbin]# ./nginx -t
2.3バージョン番号と特定の情報を表示する
[root@localhost sbin]# ./nginx -v
nginx version: nginx/1.16.1
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
configure arguments: --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi
2.4プロンプトコマンド
[root@localhost sbin]# ./nginx -h
nginx version: nginx/1.16.1
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: /usr/local/nginx/conf/nginx.conf)
-g directives : set global directives out of configuration file
2.5構成ファイルをリロードします
[root@localhost sbin]# ./nginx -s reload
2.5コア構成ファイルを指定する
[root@localhost sbin]# ./nginx -c test.conf
3関連情報
- **ブログの投稿は簡単ではありません。注意と賞賛に一生懸命取り組んできた皆さん、ありがとうございます**