LoginSignup
0
6

More than 5 years have passed since last update.

nginxについて

Last updated at Posted at 2017-01-28

nginxの用途

・静的コンテンツ配信
・アプリサーバへのリバースプロキシとして

アーキテクチャ

・イベント駆動
・イベントに応じて定められた手順を実行
・接続要求、読み込み、書き込みイベント
・Apache→クライアントの接続要求から始まる一連の処理を書くプロセスで1接続づつ処理
・I/O Multiplexing 複数のファイルディスクリプタを監視。入出力可能になるまで待機させる
・ノンブロッキングI/O
 すぐに処理できないディスクリプタとの入出力処理は中断、別の入出力処理に移ることで並行性を高めてる
・非同期I/O
 nginxはマスタプロセス、ワーカプロセスのマルチプロセス構成。
 マスタプロセスは1つ。ワーカプロセスは設定で複数起動可能。
 複数のクライアントとの入出力を並行して行うことができる
 ワーカプロセスは複数起動可能→容易なスケール。
 マスタプロセスはワーカプロセスのPIDを保持。マスタにシグナルを送ればnginx全体のプロセスを制御可。
 

インストール

#CentOSの場合
#/etc/yum.repos.d/nginx.repo を作成

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1
$ sudo yum install nginx

設定をデバッグ

ログに流れてくる変数などを出力することで確認できる。

#nginx.conf デバッグ用のLogFormatを追加

log_format for_debug "[DEBUG] $debug_val";
#sites-available内の各サイト設定に

#デバッグ用フォーマット指定
access_log /var/log/nginx/xxx.com/access.log for_debug;

location ~ \.php${
        #デバッグ用変数に確認したいデータを指定
        set $debug_val $fastcgi_script_name;

        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params; 
} 

 

まとめ

nginx@nginx.org ユーザ向けメーリングリスト
nginx-announce@nginx.org セキュリテイ等アナウンス
nginx plus Nginx, Inc.提供の商用版。

0
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
6