一、安裝 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; } }