如何在Mac上安装Nginx

1. 安装Homebrew

Last login: Fri Dec 27 20:07:12 on console
ZBMAC-d4b1fcebb:~ toman$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN to continue or any other key to abort
==> Downloading and installing Homebrew...
remote: Enumerating objects: 2915, done.
remote: Counting objects: 100% (2915/2915), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 5838 (delta 2900), reused 2906 (delta 2897), pack-reused 2923
Receiving objects: 100% (5838/5838), 1.61 MiB | 456.00 KiB/s, done.
Resolving deltas: 100% (4428/4428), completed with 643 local objects.
From https://github.com/Homebrew/brew
   686760d10..c0b916764  master     -> origin/master
 * [new tag]             2.1.10     -> 2.1.10
 * [new tag]             2.1.11     -> 2.1.11
 * [new tag]             2.1.12     -> 2.1.12
 * [new tag]             2.1.13     -> 2.1.13
 * [new tag]             2.1.14     -> 2.1.14
 * [new tag]             2.1.15     -> 2.1.15
 * [new tag]             2.1.16     -> 2.1.16
 * [new tag]             2.1.7      -> 2.1.7
 * [new tag]             2.1.8      -> 2.1.8
 * [new tag]             2.1.9      -> 2.1.9
 * [new tag]             2.2.0      -> 2.2.0
 * [new tag]             2.2.1      -> 2.2.1
 * [new tag]             2.2.2      -> 2.2.2
HEAD is now at c0b916764 Merge pull request #6857 from GauthamGoli/argv-cleanup-7
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.6.3.mavericks.bottle.tar.gz
Updated 1 tap (homebrew/core).
==> New Formulae

==> Updated Formulae

==> Renamed Formulae

==> Deleted Formulae

==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Next steps:
- Run `brew help` to get started
- Further documentation: 
    https://docs.brew.sh

2. 查看Homebrew版本信息

ZBMAC-d4b1fcebb:~ toman$ brew -v
Homebrew 2.2.2
Homebrew/homebrew-core (git revision 142a; last commit 2020-01-02)

3. 安装Nginx

ZBMAC-d4b1fcebb:~ toman$ brew install nginx
Updating Homebrew...
==> Installing dependencies for nginx: openssl@1.1 and pcre
==> Installing nginx dependency: openssl@1.1
==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.1d.high_sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/c7/c7681ee40cb3680cd9fafcdb092bde153b9d4903907d67858baa5f19025f927b?__gda__=exp=1578037194~hmac=1d51a5f8e75a599762d90994cebc266adc2530a4c3929cfe3d76a3363ed94223&response-content-disposition=
######################################################################## 100.0%
==> Pouring openssl@1.1-1.1.1d.high_sierra.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 openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.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.1d: 7,983 files, 17.9MB
==> Installing nginx dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.43.high_sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/03/0389911a93a88efd4a69b52dea8ecb872fdb55bcfff45d2f7313be5f79730861?__gda__=exp=1578037212~hmac=22ff0a7195ef23ac0948823db968f620dcd8dc673b461d004b7c3365e92a7bc0&response-content-disposition=
######################################################################## 100.0%
==> Pouring pcre-8.43.high_sierra.bottle.tar.gz
🍺  /usr/local/Cellar/pcre/8.43: 204 files, 5.5MB
==> Installing nginx
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.17.7.high_sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/54/54ba160e942f3dcfd9d557b2bd3b76159078138c08da6f7cd2ca301286c7b116?__gda__=exp=1578037219~hmac=3fe1a3c8ac017253018f0a51698c53c2c40ba99b9eefef7c6d4c1ef8cb4455f5&response-content-disposition=
######################################################################## 100.0%
==> Pouring nginx-1.17.7.high_sierra.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.17.7: 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 openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.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

4. 查看Nginx版本

ZBMAC-d4b1fcebb:~ toman$ nginx -v
nginx version: nginx/1.17.7

5. 启动Nginx

ZBMAC-d4b1fcebb:~ toman$ brew services start nginx
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 14 (delta 0), reused 7 (delta 0), pack-reused 0
Unpacking objects: 100% (14/14), done.
Tapped 1 command (43 files, 59.4KB).
==> Successfully started `nginx` (label: homebrew.mxcl.nginx)

6. 访问Nginx

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值