魔法使いの卵

WEBエンジニアの卵の成長記録

Nginxのコマンドについて

コマンドリストを出してみる

  • nginx -h
nginx version: nginx/1.8.0
Usage: nginx [-?hvVtq] [-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
  -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: /etc/nginx/)
  -c filename   : set configuration file (default: /etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file

接続のテストを行う

  • sudo nginx -t
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2015/11/14 06:39:54 [warn] 1936#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
2015/11/14 06:39:54 [emerg] 1936#0: open() "/var/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed

新しく作った設定ファイルが正常に動作するか確認したい

  • 設定ファイルをコピーする
cp /etc/nginx/nginx.conf ~/test.conf
  • 設定ファイルを書き換える作業をする
vim ~/test.conf

ごにょごにょ
  • 正常に動作するか確認する
  • sudo nginx -t -c ~/test.conf
nginx: the configuration file ~/test.conf syntax is ok
nginx: configuration file ~/test.conf test is successful

設定ファイルを置き換えサーバ設定をリロードする

  • 設定ファイルを置き換える
sudo cp ~/test.conf /etc/nginx/nginx.conf
  • サーバ設定をリロードする
sudo nginx -s reload

モジュールをビルドしたか確認する

  • nginx -V
nginx version: nginx/1.8.0
built by gcc 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

おもったこと

  • やっぱり色々便利なものがあった
  • 設定ファイルのテスト方法しらなかったので知見がたまった
  • モジュールも確認できるようになったので何がたりないのかわかった
  • yumでいれたら場合は全てのモジュールが入ってきてるっぽい