1. Nginx安裝步驟
1.1 官網介紹
http://nginx.org/en/download.html

1.2 上傳安裝包
上傳到指定目錄中 /usr/local/src

1.3 解壓Nginx 壓縮檔案

1.移動安裝目錄到指定檔案
mv nginx-1.19.4.tar.gz software/
2.修改檔案名稱
mv nginx-1.19.4 nginx
1.4 關于nginx 目錄說明

1.5 安裝nginx服務器
說明:在源檔案中執行如下命令
-
./configure

直接結果:

-
make

-
make install

1.6 nginx命令說明
說明: nginx作業目錄說明
路徑: 
命令:
1.windows命令:
1.啟動命令: start nginx
2.重啟命令: nginx -s reload
3.關閉命令: nginx -s stop
2.Linux命令:
1.啟動命令: ./nginx
2.重啟命令: ./nginx -s reload
3.關閉命令: ./nginx -s stop
1.7 修改nginx組態檔

需求說明:
1.實作圖片反向代理
2.實作tomcat負載均衡實作
具體實作:
修改完成之后,重啟nginx服務器.
#配置圖片代理服務器 http://image.jt.com:80
server {
listen 80;
server_name image.jt.com;
location / {
#root D:/JT-SOFT/images;
root /usr/local/src/images;
}
}
#配置商品后臺服務器
server{
listen 80;
server_name manage.jt.com;
location / {
#代理真實服務器地址
#proxy_pass http://localhost:8091;
#映射到集群
#proxy_pass http://jtWindows;
proxy_pass http://jtLinux;
}
}
#配置tomcat服務器集群 1.默認 輪詢策略 2.權重策略 3.ip_hash策略
upstream jtWindows {
#ip_hash; down 標識宕機 backup 備用機
#max_fails=1 表示最大的失敗次數
#fail_timeout=60s 如果訪問不通,則在60秒內,不會再次訪問故障機
server 127.0.0.1:8081 max_fails=1 fail_timeout=60s;
server 127.0.0.1:8082 max_fails=1 fail_timeout=60s;
server 127.0.0.1:8083 max_fails=1 fail_timeout=60s;
}
upstream jtLinux {
server 192.168.126.129:8081;
server 192.168.126.129:8082;
server 192.168.126.129:8083;
}
1.8.修改hosts檔案
說明:由于沒有購買image/manage.jt.com的域名,所以需要通過hosts檔案修改轉向.
修改windows中的hosts檔案:
# 京淘配置
192.168.126.129 image.jt.com
192.168.126.129 manage.jt.com
#IP 域名 映射關系
#127.0.0.1 image.jt.com
#127.0.0.1 manage.jt.com
127.0.0.1 www.jt.com
127.0.0.1 sso.jt.com
127.0.0.1 localhost
#bug 丟最后一個字母問題
1.9效果展現

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/211432.html
標籤:其他
