1、安装 Homebrew
Homebrew 能干什么?使用 Homebrew 安装 Apple 没有预装但 你需要的东西。
安装命令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"2、如果不是首次安装 Homebrew,在安装nginx时需要检查更新
brew update [这个命令很慢,可以替换成下面的清华的镜像]
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.gitcd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.gitbrew update
3、安装 nginx【查看nginx信息】brew search nginx
【安装nginx】brew install nginx
如果之前安装过,可以卸载:/usr/local/Homebrew/bin/brew uninstall nginx
Docroot is: /usr/local/var/wwwThe 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/. 【所有的配置文件在这个文件夹里】
4、常用命令
【运行nginx】nginx
【重新启动nginx】nginx -s reload
5、appServer
upstream app2backend{ server 127.0.0.1:8080;}server { listen 80; server_name v2.iqianjin.com; location / { proxy_pass http://app2backend; }}