1. 安装 Nginx
brew install nginx
2. 启动 Nginx
nginx
3.停止 Nginx
nginx -s stop
Tips:更多命令可输入nginx -h
查看。
Nginx 启动后,默认端口为 8080 , 可直接通过浏览器访问:http://localhost:8080/
即可
4. 配置 Nginx
/usr/local/etc/nginx/nginx.conf (配置文件路径)
/usr/local/var/www (服务器默认路径)
5. 更新 Nginx
nginx -s reload
6. 负载均衡
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;
}
}
}