1.nginx.org 下载nginx的稳定版zip包。
2.解压至本地目录如D:\nginx(主)。
功能:
1. cd到D:\nginx目录
2. 启动nginx: nginx -c conf\nginx.conf
3. nginx.conf 关键配置文件如下:
upstream www.wu.com{ server localhost:8090 weight=3; server localhost:9090 weight=1; } server { listen 80; #server_name localhost; server_name www.wuwh.com; location / { #proxy_pass http://www.wuwh.com ; proxy_pass http://www.wu.com ; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
4.把D:\nginx整个目录复制到 D:\nginx1 D:\nginx2(负载机)
(1)分别cd到D:\nginx1 D:\nginx2
(2)启动nginx, D:\nginx1 、D:\nginx2目录下的conf\nginx.conf文件的关键配置如下:
server{ listen 8090; server_name www.wu.com; access_log logs/access.log; location /{ index index.html; root htdocs; } }