前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Nginx升级指北

Nginx升级指北

作者头像
用户1456517
发布2019-04-29 18:17:07
7840
发布2019-04-29 18:17:07
举报

准备工作

查看当前Nginx版本

[root@test-ds-nginx ~]# nginx -v
nginx version: nginx/1.12.2

查看并备份当前版本Nginx编译配置

[root@test-ds-nginx ~]# nginx -V
nginx version: nginx/1.12.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --user=nginx --group=nginx --pid-path=/var/run/nginx/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/usr/local/nginx/temp/proxy --http-fastcgi-temp-path=/usr/local/nginx/temp/fcgi --lock-path=/var/run/nginx/nginx.lock --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_flv_module --with-debug

升级Nginx

获取Nginx

[root@test-ds-nginx ~]# cd /usr/src/
[root@test-ds-nginx src]# wget https://nginx.org/download/nginx-1.14.2.tar.gz
[root@test-ds-nginx src]# tar xf nginx-1.14.2.tar.gz

修改源文件,隐藏版本号

[root@test-ds-nginx src]# cd nginx-1.14.2
[root@test-ds-nginx nginx-1.14.2]# vim src/core/nginx.h
Line 14:
#define NGINX_VER          "nginx/" NGINX_VERSION

修改为

#define NGINX_VER          "Linux_Web_Server/" NGINX_VERSION /*modify this line*/

重新编译,切勿make install,否则将覆盖安装!

[root@test-ds-nginx nginx-1.14.2]# ./configure  --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --user=nginx --group=nginx --pid-path=/var/run/nginx/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/usr/local/nginx/temp/proxy --http-fastcgi-temp-path=/usr/local/nginx/temp/fcgi --lock-path=/var/run/nginx/nginx.lock --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_flv_module --with-debug
[root@test-ds-nginx nginx-1.14.2]# make -j4

备份旧的Nginx执行程序及安装路径

[root@test-ds-nginx nginx-1.14.2]# service nginx stop
[root@test-ds-nginx nginx-1.14.2]# tar czvf /usr/local/nginx.bak.tar.gz /usr/local/nginx/
[root@test-ds-nginx nginx-1.14.2]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old #备份旧的Nginx执行程序

将新编译的Nginx执行程序拷贝到现有Nginx执行程序目录中

[root@test-ds-nginx nginx-1.14.2]# cp objs/nginx /usr/local/nginx/sbin/nginx

重新启动

[root@test-ds-nginx nginx-1.14.2]# service nginx start
正在启动 nginx:                                           [确定]

检查是否升级成功

[root@test-ds-nginx nginx-1.14.2]# nginx -v
nginx version: Linux_Web_Server/1.14.2

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019/04/19,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 准备工作
    • 查看当前Nginx版本
      • 查看并备份当前版本Nginx编译配置
      • 升级Nginx
        • 获取Nginx
          • 修改源文件,隐藏版本号
            • 重新编译,切勿make install,否则将覆盖安装!
              • 备份旧的Nginx执行程序及安装路径
                • 将新编译的Nginx执行程序拷贝到现有Nginx执行程序目录中
                  • 重新启动
                    • 检查是否升级成功
                    领券
                    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档