7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macでnginxを導入したときの作業メモ

Last updated at Posted at 2015-01-13

インストール

homebrewでインストールする
$ brew install nginx

起動、停止、再起動

# 起動
$ sudo nginx
# 停止
$ sudo nginx -s stop
# 再起動
$ sudo nginx -s reload

プロセス確認

$ ps -ef | grep nginx | grep -v grep

設定ファイルの場所

/usr/local/etc/nginx/nginx.conf
以下の作業は、このconfを修正します。

root変更

状況に応じて決めてください

location / {
  #root html;
  root /Users/hoge/opt/htdocs;
}

設定ファイルのログ出力先、フォーマット変更

POSTデータが出力されるようにしておく

ログの出力先

/var/log/nginx/access.log

ログの出力フォーマット変更

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" "$request_body"';

静的なページでPOSTする

テスト時に必要になったので、こうやってみた

#サーバディレクティブに下記を追加など
error_page 405 =200 $uri;
7
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
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?