一、查看版本及编译参数

[root@lzn ~]# nginx  -V
nginx version: nginx/1.0.15
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_gzip_static_module --with-ipv6

二、进入src源码目录,下载nginx版本、这边用1.4.4版本的

[root@lzn ~]# cd /usr/local/src/
[root@lzn src]# wget http://nginx.org/download/nginx-1.4.4.tar.gz
--2013-12-11 07:57:46--  http://nginx.org/download/nginx-1.4.4.tar.gz
正在解析主机 nginx.org... 206.251.255.63
Connecting to nginx.org|206.251.255.63|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:768217 (750K) [application/octet-stream]
Saving to: `nginx-1.4.4.tar.gz'

100%[==================================================================================================================================>] 768,217      104K/s   in 6.7s    

2013-12-11 07:57:54 (112 KB/s) - `nginx-1.4.4.tar.gz' saved [768217/768217]

三、解压进安装目录

[root@lzn src]# tar -xf nginx-1.4.4.tar.gz
[root@lzn src]# cd nginx-1.4.4

四、安装加编译参数,注意这边只make

[root@lzn nginx-1.4.4]# ./configure  --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6
[root@lzn nginx-1.4.4]# make

五、关键步骤,升级启动,执行这步,会自动移动旧版本nginx、拷贝新版本过去、检查状态,nginx在不重载配置文件启动工作进程,然后关闭旧版nginx

[root@lzn nginx-1.4.4]# 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`

六、升级完成。

[root@lzn nginx-1.4.4]# nginx -V
nginx version: nginx/1.4.4
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48)
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_gzip_static_module --with-ipv6

七、nginx重新加载配置文件,用nginx常用命令-s reload

[root@lzn nginx-1.4.4]# nginx -s reload
[root@lzn nginx-1.4.4]# nginx -V
nginx version: nginx/1.4.4
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48)
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_gzip_static_module --with-ipv6