第一步:先下载离线安装包,包括依赖包,然后到对应主机对应目录进行解压
cd /app/soft
tar -zxvf nginx-1.22.0.tar.gz
tar -zxvf pcre-8.37.tar.gz
第二步: 进入旧版nginx安装目录下/nginx/sbin下,执行./nginx -V
目的是看旧版nginx安装的目录和安装了哪些模块,新版保持一致,防止丢失
--prefix=/app/tools/nginx的意思是指定安装位置
如 显示configure arguments: --with-http_stub_status_module --prefix=/app/tools/nginx --with-pcre=/app/soft/pcre-8.36 --with-openssl=/app/soft/openssl-1.1.1m --with-zlib=/app/soft/zlib-1.2.8 --with-http_realip_module --with-http_ssl_module --with-stream --with-stream_ssl_module
将该命令复制下来,待会升级时可以复用
第三步:进入到新解压的ng跟目录下 cd /app/soft/nginx-1.22.0
执行 ./configure --with-http_stub_status_module --prefix=/app/tools/nginx --with-pcre=/app/soft/pcre-8.36 --with-openssl=/app/soft/openssl-1.1.1m --with-zlib=/app/soft/zlib-1.2.8 --with-http_realip_module --with-http_ssl_module --with-stream --with-stream_ssl_module
此处是指定安装位置和指定安装哪些扩展模块以及模块在主机上的位置
第四步: 执行make 即进行编译
第五步:进入旧版ng目录下/sbin里面的nginx备份成nginx.old mv nginx nginx.old 然后复制 /app/soft/nginx-1.22.0/objs/nginx到旧版ng /sbin/目录下
第六步:在新版ng目录下执行make upgrade
Tips:如果执行命令提示错误信息为为指定配置文件或找不到配置文件,那么说明之前nginx启动时为未指定配置文件位置。如未指定 使用/home/yuqingzhang/ng1.18/sbin/nginx -c /home/yuqingzhang/ng1.18/conf/nginx.conf 指定一下(这个指定操作要在备份旧版nginx之前,不然重命名后找不到/sbin/nginx了)
331

被折叠的 条评论
为什么被折叠?



