nginx 在线升级

发布 : 2020-12-10 分类 : nginx 浏览 :

安装 nginx

vim /etc/yum.repos.d/nginx.repo

1
2
3
4
5
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

yum install -y nginx

开机自动启动
systemctl enable nginx.service

nginx 在线升级

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#查看当前nginx的版本 和编译配置
nginx -V

#备份 当前nginx
mv /usr/local/nginx/sbin/nginx{,.old}


cd /usr/local/src
#获取最新代码 http://nginx.org/en/download.html
wget http://nginx.org/download/nginx-1.19.5.tar.gz

tar -zxf nginx-1.19.5.tar.gz
cd nginx-1.19.5

#可以使用 nginx -V 查看编译配置
/usr/local/nginx/sbin/nginx -V

#复制上面输出的编译配置 执行编译配置
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.44 --with-openssl=/usr/local/src/openssl-1.1.1s --with-stream=dynamic --add-module=/usr/local/iguard6/igdagent/modules/nginx/iguardloader

#4核编译 加快速度
make -j 4

#编译完成后 进入编译完的目录
cd objs/

#查看编译后的配置
./nginx -V
#测试是否可用
./nginx -t
#覆盖
cp nginx /xxx/nginx/sbin/
cd ..

#运行升级程序 自动升级重启
make upgrade
#检查生产环境的版本
/usr/local/nginx/sbin/nginx -V
#检查生产环境测试能否通过
/usr/local/nginx/sbin/nginx -t

问题 openssl

可以使用单独的openssl 不和系统默认软件绑定
使用特定版本--with-openssl=/usr/local/src/openssl-1.1.1i

1
2
3
//下载解压就可以了
wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz
tar -zxf openssl-1.1.1i.tar.gz

问题 pcre

跟openssl相同--with-pcre=/usr/local/src/pcre-8.44

1
2
wget ftp://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
tar -zxf pcre-8.44.tar.gz
本文作者 : zhouinfo
原文链接 : http://blog.zhouinfo.site/2020/12/10/nginx-%E5%9C%A8%E7%BA%BF%E5%8D%87%E7%BA%A7/
版权声明 : 本博客所有文章除特别声明外,均采用 CC Apache License 2.0 许可协议。转载请注明出处!
留下足迹