標籤:style blog class c code java
1、下載 nginx
下載頁面 :
http://nginx.org/en/download.html
具體檔案:
http://nginx.org/download/nginx-1.7.0.zip
2、運行 nginx
解壓第一步下載的 nginx-1.7.0.zip 壓縮包 解壓到 c:/nginx路徑
2.1、修改監聽連接埠
由於 80 連接埠已經配置IIS ,現修改nginx 監聽連接埠
server {
listen 80;
修改為
listen 5000;
2.2 、修改 host
修改系統 host (路徑:C:\Windows\System32\drivers\etc\HOSTS):
添加配置:
127.0.0.1 wangkun.com
2.3 、啟動 cmd 命令視窗
?
| 1 2 3 4 5 6 7 8 9 10 11 12 |
cd C:\nginx // 啟動 nginx start nginx /* 常用命令 nginx -s stop // 停止nginx nginx -s reload // 重新載入設定檔 nginx -s quit // 退出nginx */ |
在瀏覽器中 瀏覽 http://wangkun.com:5000 即可查看 nginx 歡迎介面
2.4 配置nginx 叢集
2.4.1 配置 IIS 網站:
web1: 127.0.0.1:5069
web2: 127.0.0.1:5070
2.4.2 調整nginx配置
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; upstream wangkun.com { server 127.0.0.1:5069; server 127.0.0.1:5070; } server { listen 5000; server_name localhost; location / { proxy_pass http://wangkun.com; proxy_redirect default; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } |
2.4.3 驗證:
通過瀏覽器瀏覽: http://wangkun:5000
現在停止 IIS web01 ,則瀏覽的頁面就一直顯示 web02
備忘:
在生產環境中 ,可以將nginx 部署在linux上 ,有獨立的linux nginx 主機轉化請求 映射到 windows IIS上