魔法使いの卵

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

Nginxのコマンドについて(手動ver)

手動ver前提

  • こちらはパスを通していないことを前提とする

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

  • /usr/local/nginx/sbin/nginx -h
nginx version: nginx/1.9.6
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: conf/nginx.conf)
  -g directives : set global directives out of configuration file

設定のテストを行う

  • sudo/usr/local/nginx/sbin/nginx -t
  • 以下は成功例
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

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

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

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

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

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

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

  • /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.9.6
built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=www-data --group=www-data --with-http_ssl_module --with-http_realip_module