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虚拟主机的搭建的实现步骤

    Nginx虚拟主机的搭建的实现步骤

    本文主要介绍了Nginx虚拟主机的搭建的实现步骤,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-01-01
  • nginx+tomcat 通过域名访问项目的实例

    nginx+tomcat 通过域名访问项目的实例

    这篇文章主要介绍了nginx+tomcat 通过域名访问项目的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2020-05-05
  • Nginx跨域使用字体文件的配置方法

    Nginx跨域使用字体文件的配置方法

    这篇文章主要介绍了Nginx跨域使用字体文件的配置方法,使用HttpHeadersModule模块实现,需要的朋友可以参考下
    2014-06-06
  • Debian下搭建Nginx和Tomcat服务器实现负载均衡的方案

    Debian下搭建Nginx和Tomcat服务器实现负载均衡的方案

    这篇文章主要介绍了Debian下搭建Nginx和Tomcat服务器实现负载均衡的方案,其主要思想依然是动静分离并且以Nginx来进行反向代理这样的路子,需要的朋友可以参考下
    2015-12-12
  • nginx实现发布静态资源的方法

    nginx实现发布静态资源的方法

    这篇文章主要介绍了nginx实现发布静态资源的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2021-01-01
  • nginx rtmp模块编译 arm版本的问题

    nginx rtmp模块编译 arm版本的问题

    这篇文章主要介绍了nginx rtmp模块编译 arm版本的问题,pcre库和libz库都不用单独编译,在编译nginx时添加模块时一起编译,需要的朋友可以参考下
    2021-12-12
  • Nginx反向代理学习实例教程

    Nginx反向代理学习实例教程

    nginx作为web服务器一个重要的功能就是反向代理,当然你也可以使用nginx配置正向代理,这篇文章主要给大家介绍了关于Nginx反向代理的相关资料,需要的朋友可以参考下
    2021-10-10
  • Nginx动静分离实现案例代码解析

    Nginx动静分离实现案例代码解析

    这篇文章主要介绍了Nginx动静分离实现案例代码解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-08-08
  • 使用Nginx为自己的网站资源加上防盗链保护实现

    使用Nginx为自己的网站资源加上防盗链保护实现

    这篇文章主要为大家介绍了使用Nginx为自己的网站资源加上防盗链保护实现详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-08-08
  • nginx php-fpm 小VPS 优化

    nginx php-fpm 小VPS 优化

    小VPS受系统资源的限制,访问量过大,超过系统所能承受的极限时,有一部分请求就会502了。在系统资源够用的情况,优化nginx,php-fpm,以及系统本身
    2016-05-05

最新评论