1. 安裝 Nginx
brew install nginx
2. 啟動(dòng) Nginx
nginx
3.停止 Nginx
nginx -s stop
Tips:更多命令可輸入nginx -h
查看绍昂。
Nginx 啟動(dòng)后荆陆,默認(rèn)端口為 8080 崇摄, 可直接通過(guò)瀏覽器訪問(wèn):http://localhost:8080/
即可
4. 配置 Nginx
/usr/local/etc/nginx/nginx.conf (配置文件路徑)
/usr/local/var/www (服務(wù)器默認(rèn)路徑)
5. 更新 Nginx
nginx -s reload
6. 負(fù)載均衡
http{
upstream balance{
ip_hash;
server 10.10.10.1 weight=1;
server 10.10.10.2 weight=2;
}
server{
listen 8080;
location /{
proxy_pass http://balance;
}
}
}