ブログ - nginxをインストールする
nginxは高速処理を目指したWebサーバ.今回はプロキシのフロントとするのを目的としてインストールしてみる.
gaia:~ server$ brew install nginx🆑
==> Installing dependencies for nginx: pcre
==> Installing nginx dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.41.el_capitan.bottle
######################################################################## 100.0%
==> Pouring pcre-8.41.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/pcre/8.41: 204 files, 5.4MB
==> Installing nginx
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.12.2_1.el_capitan.b
######################################################################## 100.0%
==> Pouring nginx-1.12.2_1.el_capitan.bottle.tar.gz
==> Caveats
Docroot is: /usr/local/var/www🈁
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To have launchd start nginx now and restart at login:
brew services start nginx🈁
Or, if you don't want/need a background service you can just run:
nginx
==> Summary
🍺 /usr/local/Cellar/nginx/1.12.2_1: 23 files, 1MB
gaia:~ server$
ドキュメントルートは/usr/local/var/wwwで,8080ポートで動作するようだ.
ドキュメントルートを確認.
nginxをスタートさせる.
プロセスを確認.
localhost:8080で接続してみる.

サンプルページに接続できました.
nginxを停止する.
完了.
ドキュメントルートを確認.
gaia:~ server$ ls -la /usr/local/var/www🆑
total 16
drwxr-xr-x 4 server admin 136 10 17 22:16 .
drwxr-xr-x 7 server admin 238 11 23 20:46 ..
-rw-r--r-- 1 server admin 537 10 17 22:16 50x.html
-rw-r--r-- 1 server admin 612 10 17 22:16 index.html
gaia:~ server$
gaia:~ server$ brew services start nginx🆑
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Counting objects: 14, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 14 (delta 0), reused 10 (delta 0), pack-reused 0
Unpacking objects: 100% (14/14), done.
Tapped 0 formulae (43 files, 55.6KB)
==> Successfully started `nginx` (label: homebrew.mxcl.nginx)
gaia:~ server$
gaia:~ server$ ps -ef | grep nginx🆑
501 6281 1 0 8:51PM ?? 0:00.02 nginx: master process /usr/local/opt/nginx/bin/nginx -g daemon off;
501 6284 6281 0 8:51PM ?? 0:00.00 nginx: worker process
501 6289 4730 0 8:51PM ttys000 0:00.00 grep nginx
gaia:~ server$

サンプルページに接続できました.
nginxを停止する.
gaia:~ server$ brew services stop nginx🆑
Stopping `nginx`... (might take a while)
==> Successfully stopped `nginx` (label: homebrew.mxcl.nginx)
gaia:~ server$