mac 安装 nginx 环境

#1、brew search nginx

nginx
homebrew/nginx/accept-language-nginx-module
homebrew/nginx/accesskey-nginx-module
homebrew/nginx/ajp-nginx-module
homebrew/nginx/anti-ddos-nginx-module
homebrew/nginx/array-var-nginx-module
homebrew/nginx/auth-digest-nginx-module
homebrew/nginx/auth-ldap-nginx-module
homebrew/nginx/auth-pam-nginx-module
homebrew/nginx/auto-keepalive-nginx-module
homebrew/nginx/autols-nginx-module
homebrew/nginx/cache-purge-nginx-module
homebrew/nginx/captcha-nginx-module
homebrew/nginx/consistent-hash-nginx-module
homebrew/nginx/counter-zone-nginx-module
homebrew/nginx/ctpp2-nginx-module
homebrew/nginx/dav-ext-nginx-module
homebrew/nginx/dosdetector-nginx-module
homebrew/nginx/echo-nginx-module
homebrew/nginx/eval-nginx-module
homebrew/nginx/extended-status-nginx-module
homebrew/nginx/fancyindex-nginx-module
homebrew/nginx/headers-more-nginx-module
homebrew/nginx/healthcheck-nginx-module
homebrew/nginx/http-accounting-nginx-module
homebrew/nginx/http-flood-detector-nginx-module
homebrew/nginx/http-remote-passwd-nginx-module
homebrew/nginx/log-if-nginx-module
homebrew/nginx/lua-nginx-module
homebrew/nginx/mod-zip-nginx-module
homebrew/nginx/mogilefs-nginx-module
homebrew/nginx/mp4-h264-nginx-module
homebrew/nginx/nginx-full
homebrew/nginx/notice-nginx-module
homebrew/nginx/php-session-nginx-module
homebrew/nginx/push-stream-nginx-module
homebrew/nginx/realtime-req-nginx-module
homebrew/nginx/redis-nginx-module
homebrew/nginx/redis2-nginx-module
homebrew/nginx/rtmp-nginx-module
homebrew/nginx/set-misc-nginx-module
homebrew/nginx/small-light-nginx-module
homebrew/nginx/subs-filter-nginx-module
homebrew/nginx/tcp-proxy-nginx-module
homebrew/nginx/txid-nginx-module
homebrew/nginx/unzip-nginx-module
homebrew/nginx/upload-nginx-module
homebrew/nginx/upload-progress-nginx-module
homebrew/nginx/upstream-hash-nginx-module
homebrew/nginx/upstream-order-nginx-module
homebrew/nginx/ustats-nginx-module
homebrew/nginx/var-req-speed-nginx-module
homebrew/nginx/websockify-nginx-module
homebrew/nginx/xsltproc-nginx-module

#2,brew install nginx

==> Installing dependencies for nginx: pcre, openssl
==> Installing nginx dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.37.yosemite.bottle.t
######################################################################## 100.0%
==> Pouring pcre-8.37.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/pcre/8.37: 146 files, 5.9M
==> Installing nginx dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2d_1.yosemite.b
######################################################################## 100.0%
==> Pouring openssl-1.0.2d_1.yosemite.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/openssl/certs

and run
/usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺 /usr/local/Cellar/openssl/1.0.2d_1: 464 files, 18M
==> Installing nginx
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.8.0.yosemite.bottle.
######################################################################## 100.0%
==> Pouring nginx-1.8.0.yosemite.bottle.1.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 at login:
ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
Then to load nginx now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Or, if you don't want/need launchctl, you can just run:
nginx
==> Summary
🍺 /usr/local/Cellar/nginx/1.8.0: 7 files, 964K

#3,常用命令

nginx -V 查看版本,以及配置文件地址
nginx -v 查看版本
nginx -c filename 指定配置文件
nginx -h 帮助

重新加载配置|重启|停止|退出 nginx

nginx -s reload|reopen|stop|quit

打开 nginx

sudo nginx

测试配置是否有语法错误

nginx -t
Written on November 11, 2015