首先查看nginx當前版本
通過nginx -V 命令就可以查看當前的版本,已經當前版本安裝時候的一些nginx命令
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.12.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
configure arguments: --prefix=/usr/local/nginx
1.下載新版本的nginx-1.13.3.tar.gz, 解壓後,進入該目錄
使用上文同樣的configure進行配置
cd /usr/local/src/
tar -zxvf nginx-1.13.3.tar.gz
cd nginx-1.13.3
#./configure --prefix=/usr/local/nginxl
#make
2.備份之前舊的nginx文件,這裏只需要備份nginx 這個文件即可
[root@localhost sbin]# mv ./nginx ./nginx.old
3.複製新的nginx到nginx的目錄,只需要替換sbin 目錄下的nginx文件
cd /usr/local/src/nginx-1.13.3/objs
[root@localhost objs]# cp nginx /usr/local/nginx/sbin
4.執行升級
直接調用nginx命令 make upgrade 進行升級,升級的具體代碼如下:
[root@localhost nginx-1.13.3]# 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,如無錯誤提示,則升級完成
再次通過 /nginx -V 命令查看當前的版本
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.13.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
configure arguments: --prefix=/usr/local/nginx