1. 下載nginxhttp://nginx.org/en/download.html,選擇Stable version
2. 解壓至/usr/local目錄髓绽,生成nginx-1.16.1
3. 安裝gcc yum install gcc-c++
4. 安裝pcre yum install -y pcre pcre-devel
5. 安裝zlib yum install -y zlib zlib-devel
6. 安裝OpenSSL yum install -y openssl openssl-devel
7. 進(jìn)入之前解壓好的nginx目錄 cd/nginx-1.16.1
8. 使用命令./configure
9. 輸入命令make
10. 輸入命令make install,此時與nginx-1.16.1同級生成nginx目錄
11. 進(jìn)入新生成的目錄cd /usr/local/nginx/sbin
啟動:./nginx
重啟:./nginx -s reload
關(guān)閉:./nginx -s quit
12. 設(shè)置開機(jī)自啟 vim /etc/rc.local
13. 配置負(fù)載均衡,默認(rèn)端口80
upstream lpxt {
ip_hash;
server 10.0.0.10:8000; #tomcat1
server 10.0.0.11:9000; #tomcat2
}
server {
listen 80;
server_name 192.168.119.10;#訪問IP
location / {
proxy_pass http://lpxt;
}
}
14. 測試訪問:http://192.168.119.10:80/項目名