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. 进入之前解压好的nginx目录 cd/nginx-1.16.1
8. 使用命令./configure
9. 输入命令make
10. 输入命令make install,此时与nginx-1.16.1同级生成nginx目录
11. 进入新生成的目录cd /usr/local/nginx/sbin
启动:./nginx
重启:./nginx -s reload
关闭:./nginx -s quit
12. 设置开机自启 vim /etc/rc.local
13. 配置负载均衡,默认端口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/项目名