共计 1762 个字符,预计需要花费 5 分钟才能阅读完成。
摘要
当前版本:
升级版本:
1.15.0
1、按需编译新版本的Nginx
根据需求,常规编译新版本 nginx,不过只要执行到 make 就打住,不要 make install!
#1. 下载新版本nginx 1.15.0
wget http://nginx.org/download/nginx-1.15.0.tar.gz
#解压至源码目录
tar zxf nginx-1.15.0.tar.gz -C /usr/local/src/
#根据实际需要新增的模块,先准备所需文件(其实只需要解压即可,全部安装,后面编译就可以不指定路径了):
#2. 安装pcre:
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
tar -zxvf pcre-8.34.tar.gz -C /usr/local/src/
cd /usr/local/src/pcre-8.40
./configure && make && make install
#3. 安装zlib:
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure && make && make install
#4. 安装openssl:
cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz
cd openssl-1.0.1c
./configure && make && make install
#加上所需参数开始编译:
./configure --user=www --group=www \
--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-openssl=/usr/local/src/openssl-1.0.1c \ #对应openssl源码解压后的路径,下同(pcre,zlib)
--with-http_stub_status_module \
--with-pcre \
--with-pcre=/usr/local/src/pcre-8.40 \
--with-zlib=/usr/local/src/zlib-1.2.11
#执行make编译,但是不要执行make install
make
2、重命名nginx旧版本二进制文件
[root@172-20-2-12 nginx-1.15.0]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
3、从源码目录重新拷贝二进制文件
[root@172-20-2-12 nginx-1.15.0]# cp objs/nginx /usr/local/nginx/sbin/
4、在源码目录开始升级
[root@172-20-2-12 nginx-1.15.0]# 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`
5、确认版本
[root@172-20-2-12 ~]# nginx -V
nginx version: nginx/1.15.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
built with OpenSSL 1.0.1c 10 May 2012
TLS SNI support enabled
平滑升级成功!
正文完