目錄nginx
[root@localhost ~]# nginx -v nginx version: nginx/1.13.12 [root@localhost ~]# nginx -V nginx version: nginx/1.13.12 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) configure arguments: --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --with-http_xslt_module --with-pcre
[root@localhost ~]# wget http://nginx.org/download/nginx-1.14.1.tar.gz --2018-11-15 02:24:36-- http://nginx.org/download/nginx-1.14.1.tar.gz Resolving nginx.org (nginx.org)... 95.211.80.227, 206.251.255.63, 2001:1af8:4060:a004:21::e3, ... Connecting to nginx.org (nginx.org)|95.211.80.227|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1014040 (990K) [application/octet-stream] Saving to: ‘nginx-1.14.1.tar.gz’ 100%[==================================================================================================================================>] 1,014,040 117KB/s in 7.6s 2018-11-15 02:24:44 (130 KB/s) - ‘nginx-1.14.1.tar.gz’ saved [1014040/1014040] [root@localhost ~]# tar -zxf nginx-1.14.1.tar.gz
[root@localhost ~]# cd nginx-1.14.1 [root@localhost nginx-1.14.1]# ./configure --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --with-http_xslt_module --with-pcre [root@localhost nginx-1.14.1]# make #到make這一步便可,不須要執行make install
[root@localhost nginx-1.14.1]# cd /usr/local/nginx/sbin/ [root@localhost sbin]# mv nginx nginx_old
[root@localhost sbin]# cp /root/nginx-1.14.1/objs/nginx /usr/local/nginx/sbin/
[root@localhost sbin]# cd /root/nginx-1.14.1 [root@localhost nginx-1.14.1]# make upgrade #這一步會將結束舊進程,並開啓新的進程進行管理nginx的任務,從而達到平滑升級的效果 /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` 這裏須要注意的是,使用make upgrade進行平滑升級時,會默認發送USR2信號到/usr/local/nginx/logs/nginx.pid,可是若是你的pid文件位置不一致,就會出現文件不存在的ERROR 而咱們須要作的是,放棄使用make upgrade,而是直接使用如下命令,假設nginx.pid的路徑爲:/var/run/nginx.pid [root@localhost nginx-1.14.1]# /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 [root@localhost nginx-1.14.1]# kill -USR2 `cat /var/run/nginx.pid` 此時會在/var/run/下生成一個nginx.pid.oldbin的pid文件 [root@localhost nginx-1.14.1]# kill -QUIT `cat /var/run/nginx.pid.oldbin` #退出舊進程
[root@localhost nginx-1.14.1]# nginx -v nginx version: nginx/1.14.1 [root@localhost nginx-1.14.1]# nginx -V nginx version: nginx/1.14.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) configure arguments: --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --with-http_xslt_module --with-pcre