差分
このページの2つのバージョン間の差分を表示します。
| 次のリビジョン | 前のリビジョン | ||
| ja:documentation:07_technical_annexes:04_nginx [2021/06/17 13:30] – 作成 junichi | ja:documentation:07_technical_annexes:04_nginx [不明な日付] (現在) – 削除 - 外部編集 (不明な日付) 127.0.0.1 | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | ====== Nginx での Pandora FMS インストール ====== | ||
| - | {{indexmenu_n> | ||
| - | |||
| - | [[ja: | ||
| - | |||
| - | ===== NGINX+PHP-FPM のインストールと、Pandora FMS のための設定 ===== | ||
| - | |||
| - | Nginx は、HTTP, HTTPS, SMTP, POP3 および IMAP プロトコルのための高可用性 Web/ | ||
| - | |||
| - | NGINX は、apache の代替えとなるソフトウエアです。 | ||
| - | |||
| - | このガイドでは、ウェブサーバの変更方法を段階的に説明します。ここでは、CentOS 6 のマシンで、Apache を使っていて、NGINX を使いたい場合を示します。 | ||
| - | |||
| - | ==== NGINGX のインストール ==== | ||
| - | 最初に Apache を停止します。 | ||
| - | |||
| - | service httpd stop | ||
| - | |||
| - | リポジトリを保存するためにディレクトリを作成します。 | ||
| - | |||
| - | mkdir /root/temp ; cd / | ||
| - | |||
| - | http:// | ||
| - | |||
| - | wget http:// | ||
| - | |||
| - | リポジトリを追加します。 | ||
| - | |||
| - | rpm -i nginx-release-centos-6-0.el6.ngx.noarch.rpm | ||
| - | |||
| - | NGINX をインストールします。 | ||
| - | |||
| - | yum install nginx | ||
| - | |||
| - | サービスを開始します。 | ||
| - | |||
| - | service nginx start | ||
| - | |||
| - | 正しく動作しているか確認します。ブラウザを開き、< | ||
| - | |||
| - | ==== NGINX の設定 ==== | ||
| - | / | ||
| - | |||
| - | chown -R nginx:nginx / | ||
| - | |||
| - | / | ||
| - | |||
| - | < | ||
| - | user nginx; | ||
| - | |||
| - | worker_processes | ||
| - | |||
| - | error_log | ||
| - | pid / | ||
| - | |||
| - | |||
| - | events { | ||
| - | worker_connections | ||
| - | } | ||
| - | |||
| - | |||
| - | http { | ||
| - | include | ||
| - | default_type | ||
| - | |||
| - | log_format | ||
| - | ' | ||
| - | '" | ||
| - | |||
| - | access_log | ||
| - | |||
| - | sendfile | ||
| - | # | ||
| - | |||
| - | keepalive_timeout | ||
| - | |||
| - | #gzip on; | ||
| - | |||
| - | include / | ||
| - | ## en conf.d/ The line where we will add the server configuration. | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | / | ||
| - | |||
| - | nano / | ||
| - | |||
| - | サーバの設定は次の通りです。 | ||
| - | |||
| - | < | ||
| - | upstream php_backend { | ||
| - | server unix:/ | ||
| - | } | ||
| - | |||
| - | server{ | ||
| - | listen 80; | ||
| - | server_name 192.168.70.197; | ||
| - | ## otherwise if you set it to " | ||
| - | ## you could get some errors. | ||
| - | root / | ||
| - | index index.php index.html; | ||
| - | access_log | ||
| - | client_max_body_size 500M; | ||
| - | |||
| - | location ~* \.(png|jpg|jpeg|gif|ico)$ { | ||
| - | | ||
| - | | ||
| - | } | ||
| - | |||
| - | location ~* \.(css|js|xml)$ { | ||
| - | | ||
| - | | ||
| - | | ||
| - | } | ||
| - | |||
| - | location ~ \.php$ { | ||
| - | include fastcgi_params; | ||
| - | fastcgi_buffer_size 128k; | ||
| - | fastcgi_buffers 4 256k; | ||
| - | fastcgi_busy_buffers_size 256k; | ||
| - | fastcgi_intercept_errors on; | ||
| - | fastcgi_pass | ||
| - | fastcgi_index | ||
| - | fastcgi_param | ||
| - | fastcgi_param | ||
| - | fastcgi_param | ||
| - | fastcgi_param | ||
| - | fastcgi_param | ||
| - | } | ||
| - | |||
| - | location / { | ||
| - | try_files $uri $uri/ $uri.php? | ||
| - | } | ||
| - | |||
| - | } | ||
| - | </ | ||
| - | |||
| - | ログディレクトリを作成します。 | ||
| - | |||
| - | mkdir / | ||
| - | |||
| - | nginx が正しく設定できているか確認します。 | ||
| - | |||
| - | nginx -t | ||
| - | |||
| - | 新たな設定を読み込ませるために nginx を再起動します。 | ||
| - | |||
| - | service nginx restart | ||
| - | |||
| - | NGINX に関する詳細は、以下を確認してください。 | ||
| - | |||
| - | http:// | ||
| - | |||
| - | ==== Php-fpm のインストール ==== | ||
| - | php-fpm をインストールします。(CentOS のリポジトリから取得できます) | ||
| - | |||
| - | yum install php-fpm | ||
| - | |||
| - | 以下のライブラリがインストールされているか確認し、されていなければインストールします。 | ||
| - | |||
| - | yum install php-mbstring php-gd php-ldap php-snmp graphviz php-mysql | ||
| - | |||
| - | ==== Php-fpm の設定 ==== | ||
| - | / | ||
| - | |||
| - | < | ||
| - | ;listen = 127.0.0.1: | ||
| - | listen = / | ||
| - | ; | ||
| - | ; | ||
| - | ; | ||
| - | ; | ||
| - | |||
| - | listen.owner = nginx | ||
| - | listen.group = nginx | ||
| - | listen.mode = 0666 | ||
| - | |||
| - | user = nginx | ||
| - | group = nginx | ||
| - | </ | ||
| - | |||
| - | / | ||
| - | |||
| - | chown nginx:nginx / | ||
| - | |||
| - | APC をインストールします。 | ||
| - | |||
| - | yum install php-pecl-apc | ||
| - | |||
| - | APC の設定は / | ||
| - | |||
| - | < | ||
| - | ; The size of each shared memory segment, with M/G suffix | ||
| - | apc.shm_size=64M | ||
| - | </ | ||
| - | |||
| - | サービスを開始します。 | ||
| - | |||
| - | service php-fpm start | ||
| - | |||
| - | ==== 自動起動 ==== | ||
| - | システム起動時に nginx と php-fpm が起動するようにし、Apache は起動しないようにします。 | ||
| - | |||
| - | < | ||
| - | chkconfig httpd off | ||
| - | chkconfig nginx on | ||
| - | chkconfig php-fpm on | ||
| - | </ | ||
| - | |||
| - | ==== ログ ==== | ||
| - | nginx, php-fpm およびコンソールのログ(/ | ||
| - | |||
| - | === NGINX のログ === | ||
| - | / | ||
| - | |||
| - | === php-fpm のログ === | ||
| - | / | ||
| - | |||
| - | ===== NGINX と Apache の違い ===== | ||
| - | |||
| - | NGINX のインストールにより、ロード時間のパフォーマンスが改善されます。2台の同じマシン(同じメモリ、CPU、データベース)で比較した情報を示します。一方は Apache で、もう一方は NGINX です。 | ||
| - | |||
| - | メインメニュー: | ||
| - | Apache: (4,81s) | ||
| - | |||
| - | {{ wiki: | ||
| - | |||
| - | |||
| - | |||
| - | NGINX: (4,46s) | ||
| - | |||
| - | {{ wiki: | ||
| - | |||
| - | |||
| - | |||
| - | 監視設定画面: | ||
| - | Apache: (5,83s) | ||
| - | |||
| - | {{ wiki: | ||
| - | |||
| - | |||
| - | |||
| - | NGINX: (4,84s) | ||
| - | |||
| - | {{ wiki: | ||