1. cd /wxqyh/soft
  2. mv /wxqyh/soft/nginx.zip
  3. /wxqyh/component/nginx.zip
  4. cd /wxqyh/component
  5. unzip nginx.zip
  6. cd nginx
  7. yum localinstall -y *.rpm
  8. tar xf nginx-1.16.1.tar.gz
  9. tar zxf /wxqyh/component/nginx/openssl-1.0.2h.tar.gz
  10. cd /wxqyh/component/nginx/openssl-1.0.2h
  11. ./config shared zlib
  12. make depend
  13. make && make install
  14. mv /usr/bin/openssl /usr/bin/openssl.bak
  15. ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
  16. ln -s /usr/local/ssl/include/openssl /usr/include/openssl
  17. echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
  18. cd /wxqyh/component/nginx
  19. unzip nginx-sticky-module.zip
  20. cd /wxqyh/component/nginx/nginx-sticky-module
  21. sed -i 's?#include <ngx_sha1.h>?#include <ngx_sha1.h>\n#include <openssl/sha.h>\n#include <openssl/md5.h>?' /wxqyh/component/nginx/nginx-sticky-module/ngx_http_sticky_misc.c
  22. cd /wxqyh/component/nginx/nginx-1.16.1
  23. ./configure --prefix=/wxqyh/component/nginx --add-module=/wxqyh/component/nginx/nginx-sticky-module --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-http_realip_module
  24. make && make install

端口设置和负载均衡

替换配置文件

  1. cp /wxqyh/soft/nginx.conf /wxqyh/component/nginx/conf/nginx.conf
  2. vim /wxqyh/component/nginx/conf/nginx.conf

image.png
image.png

静态资源缓存

开启静态资源缓存
1.将需要开启静态缓存的tomcat webapps下面整个项目目录 拷贝到nginx的/wxqyh/component/nginx/html目录下,然后删除/wxqyh/component/nginx/html下该目录下的WEB-INF目录和META-INF目录
image.png
image.png
2.修改nginx配置,去掉注释,修改对应的项目名

  1. vim /wxqyh/component/nginx/conf/nginx.conf

image.png
3.启动
/wxqyh/component/nginx/sbin/nginx
image.png