编译安装平滑升级

编译安装平滑升级


平滑升级的步骤

  1. 获取之前的编译参数

  2. 下载新模块

  3. 重新编译软件,加上--add-module=新模块的解压路径

  4. 备份原程序并停止服务

  5. 把原程序用新程序覆盖

  6. 启动新程序


举例

nginx新增第三方模块echo-nginx-module

# 获取之前的编译参数
[root@nginx ~]# nginx -V
nginx version: nginx/1.20.0
built by gcc 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC) 
built with OpenSSL 1.1.1g FIPS  21 Apr 2020
TLS SNI support enabled
configure arguments:
--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

# 下载新模块echo-nginx-module
[root@nginx ~]# cd /usr/src/
[root@nginx src]# wget https://github.com/openresty/echo-nginx-module/archive/refs/heads/master.zip
[root@nginx src]# unzip master.zip
[root@nginx src]# ls
debug  echo-nginx-module-master  kernels  master.zip  nginx-1.20.0  nginx-1.20.0.tar.gz

# 重新编译软件
[root@nginx src]# cd nginx-1.20.0/
[root@nginx nginx-1.20.0]# ./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-master
[root@nginx nginx-1.20.0]# make

# 停止服务、备份原程序、将原程序替换 并 启动新程序
[root@nginx ~]# nginx -s stop && \
mv /usr/local/nginx/sbin/nginx /tmp/ && \
cp /usr/src/nginx-1.20.0/objs/nginx /usr/local/nginx/sbin/ && \
/usr/local/nginx/sbin/nginx

# 检查是否升级成功
[root@nginx ~]# nginx -V
nginx version: nginx/1.20.0
built by gcc 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC) 
built with OpenSSL 1.1.1g FIPS  21 Apr 2020
TLS SNI support enabled
configure arguments: --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-master

测试新模块

[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
······
server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            echo "this is a test!";
        }
······

# 检查语法是否有误
[root@nginx ~]# 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@nginx ~]# curl http://192.168.100.1
this is a test!
posted @ 2021-05-30 15:23  Serein)  阅读(81)  评论(0编辑  收藏  举报