Nginx版本升级记

前提:

1.        由nginx-0.8.46(old)升级为nginx-1.8.1(稳定版)。

2.        当前环境:(虚拟机下的LNMP)

a)        System :Centos6.3 x86_64

b)       Web server :nginx-0.8.46

c)        Database :mysql-5.5.3-m3

d)       Php :php-5.2.14

3.        当前环境与升级都是源码包的编译安装!!

过程:

1.        去官网下载nginx:

http://nginx.org/

 

2.        上传至服务器:

Sftp上传

 

3.        解压且进入nginx目录:

#tar zxvf nginx-1.8.1.tar.gz

#cd nginx-1.8.1

 

4.        配置:可自定义!

# ./configure --user=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

 

5.        编译:

#make

 

6.        备份老版本的执行文件:

#cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

 

7.        替换可执行文件:

#cp nginx新版本的解压路径/objs/nginx  /usr/local/nginx/sbin/nginx

 

8.        升级:

执行期间保证nginx在运行中,升级命令会杀死oldnginx pid。如果old nginx不允许,升级会报错:

/usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.confsyntax 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`

#make upgrade

确认升级是否成功!返回0则成功!

#echo $?

 

9.        查看nginx版本:

#/usr/local/nginx/sbin/nginx –V

nginxversion: nginx/1.8.1

built bygcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)

builtwith OpenSSL 1.0.0-fips 29 Mar 2010

TLS SNIsupport enabled

configure arguments: --user=nginx --group=nginx--prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

 

升级成功!!!!

你可能感兴趣的:(Nginx)