mac brew 安装nginx,出现nginx不能访问

  • Post author:
  • Post category:其他


根本原因是因为

 brew install nginx
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.15.1.high_sierra.bottle.tar.gz
Already downloaded: /Users/yuepeng1/Library/Caches/Homebrew/nginx-1.15.1.high_sierra.bottle.tar.gz
==> Pouring nginx-1.15.1.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.15.1: 23 files, 1.4MB

看最下面

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

主要是先运行它 brew services start nginx

这样的话nginx自启开启,然后在run nginx

这样localhost or 127.0.0.1就能访问进去了

具体nginx配置你们自行配置,我是直接修改的nginx.conf中的文件,然后配置的自文件,这样可以多配置n个二级域名



版权声明:本文为qq_36373262原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。