按照张宴的文档完成了nginx0.8+php5.2.13(fastcgi)+mysql5.5.3的安装,准备将nginx平滑升级。

1、备份nginx的可执行程序:
[root@svr2 sbin]# cp nginx /root/nginx_old
[root@svr2 sbin]# pwd
/usr/local/webserver/nginx/sbin

#执行升级信号
[root@svr2 sbin]# kill -USR2 `cat /usr/local/webserver/nginx/nginx.pid `

#系统会将nginx.pid进行重命名nginx.pid.oldbin
[root@svr2 sbin]# ll /usr/local/webserver/nginx/
total 88
drwx------ 2 www root 4096 Aug 18 02:48 client_body_temp
drwxr-xr-x 2 root root 4096 Aug 18 02:57 conf
drwx------ 2 www root 4096 Aug 17 05:40 fastcgi_temp
drwxr-xr-x 2 root root 4096 Aug 17 05:36 html
drwxr-xr-x 2 root root 4096 Aug 18 02:56 logs
-rw-r--r-- 1 root root 5 Aug 18 05:33 nginx.pid
-rw-r--r-- 1 root root 5 Aug 17 06:38 nginx.pid.oldbin
drwx------ 2 www root 4096 Aug 17 05:40 proxy_temp
drwxr-xr-x 2 root root 4096 Aug 17 05:36 sbin
drwx------ 2 www root 4096 Aug 17 05:40 scgi_temp
drwx------ 2 www root 4096 Aug 17 05:40 uwsgi_temp

#开始编译
[root@svr2 ~]# tar -xzf nginx-1.0.5.tar.gz
[root@svr2 ~]# cd nginx-1.0.5
[root@svr2 nginx-1.0.5]# ./configure --prefix=/usr/local/webserver/nginx/ \
> --with-http_ssl_module --with-http_stub_status_module --user=www --group=www
[root@svr2 nginx-1.0.5]# make && make install    

#
[root@svr2 ~]# ps -eo pid,ppid,user,vsz,wchan,command --forest | grep nginx

4125 1 root 5884 rt_sig nginx: master process /usr/local/webserver/nginx/sbin/nginx (老)
6532 4125 www 18428 322807 \_ nginx: worker process
6533 4125 www 18836 322807 \_ nginx: worker process
6534 4125 www 18428 322807 \_ nginx: worker process
6535 4125 www 18428 322807 \_ nginx: worker process
6536 4125 www 18428 322807 \_ nginx: worker process
6537 4125 www 18836 322807 \_ nginx: worker process
6538 4125 www 18772 - \_ nginx: worker process
6539 4125 www 18772 322807 \_ nginx: worker process
7644 4125 root 5756 rt_sig \_ nginx: master process /usr/local/webserver/nginx/sbin/nginx (新)
7645 7644 www 18336 322807 \_ nginx: worker process
7646 7644 www 18300 322807 \_ nginx: worker process
7647 7644 www 18300 322807 \_ nginx: worker process
7648 7644 www 18300 322807 \_ nginx: worker process
7649 7644 www 18300 322807 \_ nginx: worker process
7650 7644 www 18300 322807 \_ nginx: worker process
7651 7644 www 18300 322807 \_ nginx: worker process
7652 7644 www 18300 322807 \_ nginx: worker process    

[root@svr2 ~]# cat /usr/local/webserver/nginx/nginx.pid.oldbin
4125
[root@svr2 ~]# cat /usr/local/webserver/nginx/nginx.pid
7644

#原nginx已经停掉了,现在是新的进程在跑
[root@svr2 nginx-1.0.5]# kill -WINCH 4125
[root@svr2 ~]# ps -eo pid,ppid,user,vsz,wchan,command --forest | grep nginx
9854 7677 root 3920 pipe_w \_ grep nginx
4125 1 root 5884 rt_sig nginx: master process /usr/local/webserver/nginx/sbin/nginx
7644 4125 root 5756 rt_sig \_ nginx: master process /usr/local/webserver/nginx/sbin/nginx
7645 7644 www 18336 322807 \_ nginx: worker process
7646 7644 www 18300 322807 \_ nginx: worker process
7647 7644 www 18300 322807 \_ nginx: worker process
7648 7644 www 18300 322807 \_ nginx: worker process
7649 7644 www 18300 322807 \_ nginx: worker process
7650 7644 www 18300 322807 \_ nginx: worker process
7651 7644 www 18300 322807 \_ nginx: worker process
7652 7644 www 18300 322807 \_ nginx: worker process    

#我重启了一下,这步应该是不用的。
[root@svr2 nginx-1.0.5]# kill -QUIT 4125

#现在只有7644这个进程在跑
[root@svr2 ~]# ps -eo pid,ppid,user,%cpu,vsz,wchan,command | grep nginx
7644 1 root 0.0 5888 rt_sig nginx: master process /usr/local/webserver/nginx/sbin/nginx
9883 7644 www 0.0 18760 322807 nginx: worker process
9884 7644 www 0.0 18432 322807 nginx: worker process
9885 7644 www 0.0 18432 322807 nginx: worker process
9886 7644 www 0.0 18432 322807 nginx: worker process
9887 7644 www 0.0 18432 322807 nginx: worker process
9888 7644 www 0.0 18432 322807 nginx: worker process
9889 7644 www 0.0 18432 322807 nginx: worker process
9890 7644 www 0.0 18432 322807 nginx: worker process
9903 7677 root 0.0 3924 pipe_w grep nginx

看下nginx的可执行文件:
[root@svr2 ~]# ll /usr/local/webserver/nginx/sbin/
total 7428
-rwxr-xr-x 1 root root 3818413 Aug 18 05:39 nginx
-rwxr-xr-x 1 root root 3765437 Aug 17 05:36 nginx.old

#系统版本1.0.5
[root@svr2 ~]# /usr/local/webserver/nginx/sbin/nginx -v
nginx: nginx version: nginx/1.0.5