一、安装 Homebrewjava
Homebrew 能干什么?使用 Homebrew 安装 Apple 没有预装但 你须要的东西。nginx
安装命令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"git
二、若是不是首次安装 Homebrew,在安装nginx时须要检查更新github
brew update [这个命令很慢,能够替换成下面的清华的镜像]ruby
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.gitapp
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.gitcurl
brew updateurl
三、安装 nginxcode
【查看nginx信息】brew search nginxserver
【安装nginx】brew install nginx
若是以前安装过,能够卸载:/usr/local/Homebrew/bin/brew uninstall 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/. 【全部的配置文件在这个文件夹里】
四、经常使用命令
【运行nginx】nginx
【从新启动nginx】nginx -s reload
五、appServer
upstream app2backend{ server 127.0.0.1:8080; } server { listen 80; server_name v2.iqianjin.com; location / { proxy_pass http://app2backend; } }