平滑升级的步骤
- 获取之前的编译参数
- 下载新模块
- 重新编译软件,加上–add-module=新模块的解压路径
- 备份原程序并停止服务
- 把原程序用新程序覆盖
- 启动新程序
环境说明
主机名 | IP | 作用 |
---|---|---|
JLin | 192.168.23.180 | Nginx |
JiaL | 192.168.23.161 | test |
nginx新增第三方模块echo-nginx-module
// 获取之前的编译参数
[root@JLin ~]# nginx -V
// 下载新模块echo-nginx-module
[root@JLin ~]# cd /usr/src/
[root@JLin src]# wget https://github.com/openresty/echo-nginx-module/archive/refs/heads/JLin.zip
[root@JLin src]# unzip JLin.zip
[root@JLin src]# ls
debug echo-nginx-module-JLin kernels JLin.zip nginx-1.20.1 nginx-1.20.1.tar.gz
// 重新编译软件
[root@JLin src]# cd nginx-1.20.1/
[root@JLin nginx-1.20.1]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--add-module=/usr/src/echo-nginx-module-JLin
[root@matser nginx-1.20.1]# make
// 停止服务、备份原程序、将原程序替换 并 启动新程序
[root@JLin src]# nginx -s stop && \
> mv /usr/local/nginx/sbin/nginx /tmp/ && \
> cp /usr/src/nginx-1.20.1/objs/nginx /usr/local/nginx/sbin/ && \
> /usr/local/nginx/sbin/nginx
// 检查是否升级成功
[root@JLin ~]# nginx -V
测试新模块功能
[root@JLin ~]# vim /usr/local/nginx/conf/nginx.conf
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
echo "JLin";
}
# 检查语法是否有误
[root@JLin ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@nginx ~]# nginx -s reload
验证
[root@JiaL ~]# curl http://192.168.23.180:8080
JLin