共计 3992 个字符,预计需要花费 10 分钟才能阅读完成。
Nginx1.8.0 平滑升级到 1.10.1,不间断服务。
1. 先查看当前的版本及原来安装编译时候的参数路径文件信息。
#/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.8.0
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
built with OpenSSL 1.0.1c 10 May 2012
TLS SNI support enabled
configure
arguments: –user=nginx –group=nginx –prefix=/usr/local/nginx
–with-http_ssl_module –with-openssl=-1.0.1c
–with-pcre=/soft/pcre-8.21 –with-zlib=/soft/zlib-1.2.8
–with-http_stub_status_module –with-threads -l_module
–with-http_flv_module –with-http_stub_status_module
–with-http_gzip_static_module –http-client-bodyar/tmp/nginx/client/
–http-proxy-temp-path=/var/tmp/nginx/proxy/
–http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
temp-path=/var/tmp/nginx/uwsgi –http-scgi-temp-path=/var/tmp/nginx/scgi
※这是以前编译的参数。编辑新版本需要用到。
2. 下载新版本:http://nginx.org/en/download.html 解压、编译
# tar -zxvf nginx-1.10.1.tar.gz
# cd nginx-1.10.1
#
./configure –user=nginx –group=nginx –prefix=/usr/local/nginx
–with-http_ssl_module –with-openssl=/soft/openssl-1.0.1c
–with-pcre=/soft/pcre-8.21 –with-zlib=/soft/zlib-1.2.8
–with-http_stub_status_module –with-threads –with-http_ssl_module
–with-http_flv_module –with-http_stub_status_module
–with-http_gzip_static_module
–http-client-body-temp-path=/var/tmp/nginx/client/
–http-proxy-temp-path=/var/tmp/nginx/proxy/
–http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
–http-scgi-temp-path=/var/tmp/nginx/scgi
# make
编译安装后可以执行 echo $? 查看是否成功,返回值为 0 说明正确。
3. 执行完后,不要 make install,重名 /sbin/nginx 为 nginx.old
# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
4. 复制编译后 objs 目录下的 nginx 文件到 nginx 的安装目录 sbin 下
# cp objs/nginx /usr/local/nginx/sbin/
5. 测试一下新复制过来文件生效情况:
# /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
6. 让 nginx 把 nginx.pid 文件修改成 nginx.pid.oldbin,随即启动 nginx,实现不间断服务。
# kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
此时查看 nginx 进程,可以看到新建立的进程和以前的进程同时存在.
查看进程 pid 文件:
[root@Nginx ~]#cd /usr/local/nginx/logs
[root@Nginx logs]# ls
access.log error.log nginx.pid nginx.pid.oldbin
结束 nginx.pid.oldbin:
# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
结束后查看 nginx 进程,此时可以看到 nginx 进程是新建立的进程,之前的进程已结束。
【QUIT 表示处理完当前请求后没关闭进程;
HUP 表示重新加载配置,也就是关闭原有进程,并开启新的工作进程,不会中断用户访问,可以平滑重启 nginx;
USR1 用于 nginx 日志切换,即重新打开一个日志文件;
USR2 用于平滑升级可执行程序;
WINCH 从容关闭工作进程】
7. 升级完成,最后在看一下升级后的版本。
[root@Nginx~]# nginx -tv
nginx version: nginx/1.10.1
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 -V
nginx version: nginx/1.10.1
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
built with OpenSSL 1.0.1c 10 May 2012
TLS SNI support enabled
configure
arguments: –user=nginx –group=nginx –prefix=/usr/local/nginx
–with-http_ssl_module –with-openssl=/soft/openssl-1.0.1c
–with-pcre=/soft/pcre-8.21 –with-zlib=/soft/zlib-1.2.8
–with-http_stub_status_module –with-threads –with-http_ssl_module
–with-http_flv_module –with-http_stub_status_module
–with-http_gzip_static_module
–http-client-body-temp-path=/var/tmp/nginx/client/
–http-proxy-temp-path=/var/tmp/nginx/proxy/
–http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
–http-scgi-temp-path=/var/tmp/nginx/scgi
[root@Nginx ~]#
CentOS 7 下 Nginx 服务器的安装配置 http://www.linuxidc.com/Linux/2017-04/142986.htm
CentOS 上安装 Nginx 服务器实现虚拟主机和域名重定向 http://www.linuxidc.com/Linux/2017-04/142642.htm
CentOS 6.8 安装 LNMP 环境(Linux+Nginx+MySQL+PHP)http://www.linuxidc.com/Linux/2017-04/142880.htm
Linux 下安装 PHP 环境并配置 Nginx 支持 php-fpm 模块 http://www.linuxidc.com/Linux/2017-05/144333.htm
Nginx 服务的 SSL 认证和 htpasswd 认证 http://www.linuxidc.com/Linux/2017-04/142478.htm
Linux 中安装配置 Nginx 及参数详解 http://www.linuxidc.com/Linux/2017-05/143853.htm
Nginx 日志过滤 使用 ngx_log_if 不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm
CentOS 7.2 下 Nginx+PHP+MySQL+Memcache 缓存服务器安装配置 http://www.linuxidc.com/Linux/2017-03/142168.htm
CentOS6.9 编译安装 Nginx1.4.7 http://www.linuxidc.com/Linux/2017-06/144473.htm
Nginx 的详细介绍 :请点这里
Nginx 的下载地址 :请点这里
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-07/145396.htm