D11-Nginx-Upgrade
有两种情况下需要升级Nginx:
1 要升级到Nginx 的新版本
2 要为Nginx 添加新的模块
1 查看Nginx版本 与 配置参数
- /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
- /usr/local/nginx/sbin/nginx -s stop
3 升级新版本Nginx
- tar zxf nginx-1.2.3.tar.gz
- cd nginx-1.2.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
- make
注意:没有make install
4 备份
- cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
- cp /root/nginx-1.2.3/objs/nginx /usr/local/nginx/sbin/
- cp: overwrite `/usr/local/nginx/sbin/nginx'? y
注意:旧版本(sbin/nginx)仍可使用
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
- /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 比较
- du -sh *
6.2M nginx
4.3M nginx.old
7 启动nginx
- /usr/local/nginx/sbin/nginx
参考
平滑升级你的Nginx
PS: 这里未能实现nginx 在线升级。
#update 20121221 stub_status模块
Nginx中的stub_status模块主要用于查看Nginx的一些状态信息, 如果你要使用stub_status模块模块,则要在编译安装Nginx时指定,或者添加.
- 查看Nginx版本 与 配置参数
- 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
- 配置并编译
- tar zxf nginx-1.2.3.tar.gz
- tar zxf pcre-8.12.tar.gz
- ./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
- make
- 注意:没有make install
- 备份
- nginx -s stop
- 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/
- cp: overwrite `/usr/local/nginx/sbin/nginx'? y
- 测试
- /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
- /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 --with-http_stub_status_module
- 配置
- vim /usr/local/nginx/conf/vhosts/www.test.com
- location /nginx-status {
- auth_basic "NginxStatus";
- allow 192.168.4.35;
- deny all;
- stub_status on;
- access_log on;
- }
- 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
- nginx
结束
更多请:
linux 相关 37275208
vmware 虚拟化相关 166682360
本文转自 dongnan 51CTO博客,原文链接:http://blog.51cto.com/dngood/1017670