cd /wxqyh/soft
mv /wxqyh/soft/nginx.zip
/wxqyh/component/nginx.zip
cd /wxqyh/component
unzip nginx.zip
cd nginx
yum localinstall -y *.rpm
tar xf nginx-1.16.1.tar.gz
tar zxf /wxqyh/component/nginx/openssl-1.0.2h.tar.gz
cd /wxqyh/component/nginx/openssl-1.0.2h
./config shared zlib
make depend
make && make install
mv /usr/bin/openssl /usr/bin/openssl.bak
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
cd /wxqyh/component/nginx
unzip nginx-sticky-module.zip
cd /wxqyh/component/nginx/nginx-sticky-module
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
cd /wxqyh/component/nginx/nginx-1.16.1
./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
make && make install
端口设置和负载均衡
替换配置文件
cp /wxqyh/soft/nginx.conf /wxqyh/component/nginx/conf/nginx.conf
vim /wxqyh/component/nginx/conf/nginx.conf
静态资源缓存
开启静态资源缓存
1.将需要开启静态缓存的tomcat webapps下面整个项目目录 拷贝到nginx的/wxqyh/component/nginx/html目录下,然后删除/wxqyh/component/nginx/html下该目录下的WEB-INF目录和META-INF目录
2.修改nginx配置,去掉注释,修改对应的项目名
vim /wxqyh/component/nginx/conf/nginx.conf
3.启动
/wxqyh/component/nginx/sbin/nginx