D11-Nginx-Upgrade

简介:

D11-Nginx-Upgrade

 

有两种情况下需要升级Nginx:

1 要升级到Nginx 的新版本

2 要为Nginx 添加新的模块
 

 

1 查看Nginx版本 与 配置参数

 
  1. /usr/local/nginx/sbin/nginx -V 

nginx version: nginx/0.8.52
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-46)
TLS SNI support disabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_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

 

2 关闭Nginx

 
  1. /usr/local/nginx/sbin/nginx -s stop 


3 升级新版本Nginx

 
  1. tar zxf nginx-1.2.3.tar.gz 
  2. cd nginx-1.2.3 
  3. ./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.12/ --with-openssl=/usr/local/openssl/ --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --user=www --group=www 
  4. make 

注意:没有make install

4 备份

 
  1. cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old 
  2. cp /root/nginx-1.2.3/objs/nginx /usr/local/nginx/sbin/ 
  3. cp: overwrite `/usr/local/nginx/sbin/nginx'? 

注意:旧版本(sbin/nginx)仍可使用

5 测试

 
  1. /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

 
  1. /usr/local/nginx/sbin/nginx -V 

nginx version: nginx/1.2.3
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-46)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-pcre=../pcre-8.12/ --with-openssl=/usr/local/openssl/ --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --user=www --group=www

6 比较

 
  1. du -sh * 

6.2M    nginx
4.3M    nginx.old

7 启动nginx

 
  1. /usr/local/nginx/sbin/nginx  



参考
平滑升级你的Nginx 

PS: 这里未能实现nginx 在线升级

#update 20121221  stub_status模块

Nginx中的stub_status模块主要用于查看Nginx的一些状态信息, 如果你要使用stub_status模块模块,则要在编译安装Nginx时指定,或者添加.

 
  1. 查看Nginx版本 与 配置参数 
  2. nginx -V 
  3. nginx version: nginx/1.2.3 
  4. built by gcc 4.1.2 20080704 (Red Hat 4.1.2-46) 
  5. TLS SNI support enabled 
  6. configure arguments: --prefix=/usr/local/nginx --with-pcre=../pcre-8.12/ --with-openssl=/usr/local/openssl/ --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --user=www --group=www 
  7.  
  8. 配置并编译 
  9. tar zxf nginx-1.2.3.tar.gz 
  10. tar zxf pcre-8.12.tar.gz 
  11. ./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.12/ --with-openssl=/usr/local/openssl/ --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --user=www --group=www --with-http_stub_status_module  
  12. make 
  13. 注意:没有make install 
  14.  
  15. 备份 
  16. nginx -s stop 
  17. cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old.2 
  18. cp /root/nginx-1.2.3/objs/nginx /usr/local/nginx/sbin/  
  19. cp: overwrite `/usr/local/nginx/sbin/nginx'? y  
  20.  
  21. 测试 
  22. /usr/local/nginx/sbin/nginx -t  
  23. nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok 
  24. nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful 
  25. /usr/local/nginx/sbin/nginx -V 
  26. nginx version: nginx/1.2.3 
  27. built by gcc 4.1.2 20080704 (Red Hat 4.1.2-46) 
  28. TLS SNI support enabled 
  29. configure arguments: --prefix=/usr/local/nginx --with-pcre=../pcre-8.12/ --with-openssl=/usr/local/openssl/ --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --user=www --group=www --with-http_stub_status_module 
  30.  
  31. 配置 
  32. vim /usr/local/nginx/conf/vhosts/www.test.com 
  33.         location /nginx-status { 
  34.              auth_basic              "NginxStatus"; 
  35.              allow 192.168.4.35; 
  36.              deny all; 
  37.              stub_status on; 
  38.              access_log  on; 
  39.         } 
  40.  
  41. nginx -t 
  42. nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok 
  43. nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful 
  44. nginx  


结束
更多请:
linux 相关 37275208
vmware 虚拟化相关  166682360


本文转自 dongnan 51CTO博客,原文链接:http://blog.51cto.com/dngood/1017670


相关文章
|
7月前
|
应用服务中间件 Linux 网络安全
nginx的安装及使用
nginx的安装及使用
88 1
|
16天前
|
缓存 负载均衡 应用服务中间件
Nginx安装与使用: Nginx之编译安装的nginx加入systemctl、Nginx命令
Nginx安装与使用: Nginx之编译安装的nginx加入systemctl、Nginx命令
50 0
|
8月前
|
Java 应用服务中间件 编译器
安装Nginx服务
安装Nginx运行所需要的插件
59 1
|
5月前
|
应用服务中间件 nginx
如何安装Nginx
如何安装Nginx
166 0
|
8月前
|
应用服务中间件 Linux 网络安全
nginx--安装
nginx--安装
|
10月前
|
应用服务中间件 nginx C语言
linx安装nginx
1.安装依赖 yum -y install gcc pcre-devel zlib-devel openssl opensll-devel 2.下载安装包 下载地址: https://nginx.org/download/ 使用wget进行下载: wget https://nginx.org/download/nginx-1.16.1.tar.gz 具体版本可以去网页自行选择 如果没有wget命令,安装一下:
72 1
|
10月前
|
tengine 负载均衡 算法
Nginx的安装
Nginx的安装
|
应用服务中间件 Linux nginx
nginx 安装
nginx 安装
|
Ubuntu 应用服务中间件 Shell
Nginx 安装
Nginx 安装
140 0
|
应用服务中间件 nginx
安装nginx
配置/etc/nginx/conf.d/default.conf