正好有一台测试机
试试nginx升级
原来版本是nginx0.8.54
下载最新版的nginx
#wget http://nginx.org/download/nginx-0.9.5.tar.gz
解压缩
#tar vxzf nginx-0.9.5.tar.gz
新版本编译
root@debian:~/nginx-0.9.5# cd nginx-0.9.5/
root@debian:~/nginx-0.9.5# ./configure
root@debian:~/nginx-0.9.5# make
make -f objs/Makefile
make[1]: Entering directory `/root/nginx-0.9.5′
gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wunused-function -Wunused-variable -Wunused-value -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \……………………中间省略………………………………………….
make[1]: Leaving directory `/root/nginx-0.9.5′
make -f objs/Makefile manpage
make[1]: Entering directory `/root/nginx-0.9.5′
sed -e “s|%%PREFIX%%|/usr/local/nginx|” \
-e “s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|” \
-e “s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|” \
-e “s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|” \
< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/root/nginx-0.9.5′
编译完成
开始升级
root@debian:~/nginx-0.9.5# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
关键 拷贝objs下的nginx
root@debian:~/nginx-0.9.5# cp objs/nginx /usr/local/nginx/sbin/
关键 升级
root@debian:~/nginx-0.9.5# 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@debian:~/nginx-0.9.5# /usr/local/nginx/sbin/nginx -v nginx: nginx version: nginx/0.9.5
确实是无缝升级的,中间没有停顿
———————————nginx自动更新脚本 update 2011-06-01————————————–
root@debian:~# vim nginxupdate.sh
#!/bin/bash #for nginx updating version=`curl http://nginx.org/en/download.html | sed 's/.tar.gz.*$//g' | sed 's/^.*download\/nginx-//g'` wget http://nginx.org/download/nginx-${version}.tar.gz tar vxzf nginx-${version}.tar.gz cd nginx-${version}/ ./configure make mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old cp objs/nginx /usr/local/nginx/sbin/ make upgrade cd .. rm -rf nginx-${version} rm -f nginx-${version}.tar.gz
在cron里加入,每个礼拜更新一次
0 0 * * 0 bash /root/nginxupdate.sh
Leave a Reply