Nginx1.8.0版本平滑升级新版本1.9.7

 更新时间:2016年02月23日 11:16:44   作者:模范生  
这篇文章主要介绍了Nginx1.8.0版本平滑升级新版本1.9.7的相关资料,需要的朋友可以参考下

 首先查看现在环境nginx的版本为1.8.0 编译的参数只指定了安装路径;

复制代码 代码如下:

[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
configure arguments: --prefix=/usr/local/nginx

平滑升级步骤如下:

下载nginx1.9.7版本,解压并进入解压后的目录

复制代码 代码如下:

[root@localhost ~]# wget -P /usr/local/src/ http://nginx.org/download/nginx-1.9.7.tar.gz
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar -zxvf nginx-1.9.7.tar.gz
[root@localhost src]# cd nginx-1.9.7

编译安装之前查看nginx进程ID信息:

复制代码 代码如下:

[root@localhost nginx-1.9.7]# ps -ef |grep nginx
root 894 1 0 16:06 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 896 894 0 16:06 ? 00:00:00 nginx: worker process
nobody 897 894 0 16:06 ? 00:00:00 nginx: worker process

编译安装:指定用户www 支持ssl 支持pcre 支持状态查询 支持静态压缩模块;

复制代码 代码如下:

[root@localhost nginx-1.9.7]# ./configure --user=www --group=www --prefix=/usr/local/nginx/ --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module

编译安装后可以echo $?查看是否成功,成功后只需要执行make,不需要make install;

复制代码 代码如下:

[root@localhost nginx-1.9.7]# make

平滑升级,先移走现有的nginx二进制文件

复制代码 代码如下:

[root@localhost nginx-1.9.7]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

拷贝新生成的nginx二进制文件到指定目录

复制代码 代码如下:

[root@localhost nginx-1.9.7]# cp objs/nginx /usr/local/nginx/sbin/

执行升级命令

复制代码 代码如下:

[root@localhost nginx-1.9.7]# make upgrade
/usr/local/nginx//sbin/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
kill -USR2 `cat /usr/local/nginx//logs/nginx.pid`
sleep 1
test -f /usr/local/nginx//logs/nginx.pid.oldbin
kill -QUIT `cat /usr/local/nginx//logs/nginx.pid.oldbin`

查看版本,发现已经是1.9.7版本,编译的参数也存在;

复制代码 代码如下:

[root@localhost nginx-1.9.7]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.9.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx/ --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module

创建www用户

复制代码 代码如下:

[root@localhost nginx-1.9.7]# useradd -s /sbin/nologin -M www

查看nginx进程 PID已经更改

复制代码 代码如下:

[root@localhost sbin]# ps -ef |grep nginx
root 3814 1 0 16:23 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 3815 3814 0 16:23 ? 00:00:00 nginx: worker process
nobody 3816 3814 0 16:23 ? 00:00:00 nginx: worker process

修改nginx.conf配置文件,更改用户和用户组为www用户,保存退出,重启nginx服务;

复制代码 代码如下:

[root@localhost conf]# ps -ef |grep nginx
root 3814 1 0 16:23 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
www 4200 3814 0 16:48 ? 00:00:00 nginx: worker process
www 4201 3814 0 16:48 ? 00:00:00 nginx: worker process

Nginx1.8.0版本平滑升级新版本1.9.7就给大家介绍到这里,希望对大家有所帮助!

相关文章

  • Nginx(Tengine)启用 SPDY 支持的配置方法

    Nginx(Tengine)启用 SPDY 支持的配置方法

    当老迈的 HTTP 协议逐渐不能满足人们需求的时候,Google 的 SPDY 协议出现在面前,那么这个长期以来一直被认为是 HTTP 2.0 唯一可行选择的 SPDY 是什么呢?当下我们如何能部署上 SPDY 呢
    2014-12-12
  • Nginx error_page自定义错误页面设置过程

    Nginx error_page自定义错误页面设置过程

    这篇文章主要介绍了Nginx error_page自定义错误页面设置过程,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2022-12-12
  • nginx报错connect() failed(111: Connection refused)while connecting to upstream解决方法

    nginx报错connect() failed(111: Connection refus

    本文主要介绍了nginx报错connect() failed(111: Connection refused)while connecting to upstream解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-06-06
  • nginx proxy_set_header的具体实现

    nginx proxy_set_header的具体实现

    proxy_set_header 是 Nginx 配置中的一个重要指令,本文主要介绍了nginx proxy_set_header的具体实现,具有一定的参考价值,感兴趣的可以了解一下
    2024-07-07
  • 浅析nginx刚刚发布的JavaScript能力nginScript

    浅析nginx刚刚发布的JavaScript能力nginScript

    Nginx [engine x]是全球最受欢迎,也是最优秀的web服务器、反向代理服务器。nginScript是JavaScript/ECMAscript的子集,nginScript不是通过V8引擎实现的。本文给大家介绍nginx刚刚发布的JavaScript能力nginScript,感兴趣的朋友跟着小编一起了解了解吧
    2015-09-09
  • Nginx鉴权、限流问题

    Nginx鉴权、限流问题

    这篇文章主要介绍了Nginx鉴权、限流问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2024-06-06
  • 单台web服务器如何尽可能的提高网站性能

    单台web服务器如何尽可能的提高网站性能

    一个网站,对于个人或小公司来说,前期直接上集群的开销是比较大的,那么采用单台服务器如何才能尽可能的提高网站效率呢?
    2014-06-06
  • 如何在centos7中安装nginx

    如何在centos7中安装nginx

    近期做项目用到了nginx,所以自己动手来在Centos7上安装nginx,以下是安装步骤。
    2018-09-09
  • 使用nginx设置代理服务器

    使用nginx设置代理服务器

    今天小编就为大家分享一篇关于使用nginx设置代理服务器,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
    2018-12-12
  • 详解Linux中Nginx反向代理下的tomcat集群

    详解Linux中Nginx反向代理下的tomcat集群

    本篇文章主要介绍了详解Linux中Nginx反向代理下的tomcat集群,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-05-05

最新评论