Mac 安装

Mac OSX 安装特别简单,首先你需要安装 Brew, 通过 brew 快速安装 nginx

安装nginx

  1. brew install nginx
  2. # Updating Homebrew...
  3. # ==> Auto-updated Homebrew!
  4. # Updated 2 taps (homebrew/core, homebrew/cask).
  5. # ==> Updated Formulae
  6. # ==> Installing dependencies for nginx: openssl, pcre
  7. # ==> Installing nginx dependency: openssl
  8. # ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2o_1.high_sierra.bottle.tar.gz
  9. # ######################################################################## 100.0%
  10. # ==> Pouring openssl-1.0.2o_1.high_sierra.bottle.tar.gz
  11. # ==> Caveats
  12. # A CA file has been bootstrapped using certificates from the SystemRoots
  13. # keychain. To add additional certificates (e.g. the certificates added in
  14. # the System keychain), place .pem files in
  15. # /usr/local/etc/openssl/certs
  16. #
  17. # and run
  18. # /usr/local/opt/openssl/bin/c_rehash
  19. #
  20. # This formula is keg-only, which means it was not symlinked into /usr/local,
  21. # because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
  22. #
  23. # If you need to have this software first in your PATH run:
  24. # echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc
  25. #
  26. # For compilers to find this software you may need to set:
  27. # LDFLAGS: -L/usr/local/opt/openssl/lib
  28. # CPPFLAGS: -I/usr/local/opt/openssl/include
  29. # For pkg-config to find this software you may need to set:
  30. # PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
  31. #
  32. # ==> Summary
  33. # ? /usr/local/Cellar/openssl/1.0.2o_1: 1,791 files, 12.3MB
  34. # ==> Installing nginx dependency: pcre
  35. # ==> Downloading https://homebrew.bintray.com/bottles/pcre-8.42.high_sierra.bottle.tar.gz
  36. # ######################################################################## 100.0%
  37. # ==> Pouring pcre-8.42.high_sierra.bottle.tar.gz
  38. # ? /usr/local/Cellar/pcre/8.42: 204 files, 5.3MB
  39. # ==> Installing nginx
  40. # ==> Downloading https://homebrew.bintray.com/bottles/nginx-1.13.12.high_sierra.bottle.tar.gz
  41. # ######################################################################## 100.0%
  42. # ==> Pouring nginx-1.13.12.high_sierra.bottle.tar.gz
  43. # ==> Caveats
  44. # Docroot is: /usr/local/var/www
  45. #
  46. # The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
  47. # nginx can run without sudo.
  48. #
  49. # nginx will load all files in /usr/local/etc/nginx/servers/.
  50. #
  51. # To have launchd start nginx now and restart at login:
  52. # brew services start nginx
  53. # Or, if you don't wacd /usr/local/Cellar/nginx/1.13.12/n just run:
  54. # cd /usr/local/Cellar/nginx/1.13.12/

启动服务

注意默认端口不是 8080 查看确认端口是否被占用。

  1. brew services start nginx
  2. # http://localhost:8080/