Nginx 采用 Homebrew 安装

  • 使用 Homebrew 安装 Nginx,安装如下所示
dev:Homebrew shuxiaoyuan$ brew install nginx
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openssl%401.1-1.1.1g.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/pcre-8.44.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/nginx-1.19.1.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Installing dependencies for nginx: openssl@1.1 and pcre
==> Installing nginx dependency: openssl@1.1
==> Pouring openssl@1.1-1.1.1g.mojave.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@1.1/certs

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

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> /Users/shuxiaoyuan/.bash_profile

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

==> Summary
 /usr/local/Cellar/openssl@1.1/1.1.1g: 8,059 files, 18MB
==> Installing nginx dependency: pcre
==> Pouring pcre-8.44.mojave.bottle.tar.gz
 /usr/local/Cellar/pcre/8.44: 204 files, 5.5MB
==> Installing nginx
==> Pouring nginx-1.19.1.mojave.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.19.1: 25 files, 2.1MB
==> Caveats
==> openssl@1.1
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

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

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> /Users/shuxiaoyuan/.bash_profile

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

==> nginx
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
  • 一些命令,差不多,启动默认是 8080 端口,安装完成后都会告诉你,具体看上面的
# 检查配置文件
nginx -t

# 重新加载配置文件
nginx -s reload

# 启动,停止,重启
brew services start nginx
brew services stop nginx
brew services restart nginx

# 配置文件位置
/usr/local/etc/nginx/nginx.conf