1、打开终端, 查看是否已经安装了Homebrew, 直接终端输入命令
localhost:~ xxx$ man brew
如果Mac已经安装了, 会显示一些命令的帮助信息. 此时输入Q退出即可
5、查询要安装的软件nginx是否存在
localhost:~ xxx$ brew search nginx
6、安装nginx*
localhost:~ xxx$ brew install nginx
==> 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
查看nginx配置文件目录
open /usr/local/etc/nginx/
查看ginx被安装到的目录
open /usr/local/Cellar/nginx
7、启动nginx*
localhost:~ xxx$ sudo nginx
测试是否成功
打开浏览器访问:localhost:8080
出现下图 表示成功
8 关闭nginx*
localhost:~ xxx$ sudo nginx -s stop