添加--with-http_realip_module
不用停止服务,平滑升级,老的nginx进程处理完所有请求后退出,新的nginx进程处理新的请求
备份nginx
cp /opt/nginx/sbin/nginx /opt/nginx/sbin/nginx20160217
cp /opt/nginx/conf/nginx.conf /opt/nginx/conf/nginx20160217.conf
查看已安装模块
/opt/nginx/sbin/nginx -V
--prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module
安装nginx
cd /opt/nginx-1.8.1
tar zxvf nginx-1.8.1_ssi.tar.gz
cd nginx-1.8.1
./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module
make
(注意不是make install)
备份nginx为nginx.old
\cp -rf /opt/nginx/sbin/nginx /opt/nginx/sbin/nginx.old
拷贝新的nginx
\cp -rf /opt/nginx-1.8.1/nginx-1.8.1/objs/nginx /opt/nginx/sbin/nginx
升级
make upgrade
/opt/nginx/sbin/nginx -t
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
kill -USR2 `cat /opt/nginx/logs/nginx.pid`
sleep 1
test -f /opt/nginx/logs/nginx.pid.oldbin
kill -QUIT `cat /opt/nginx/logs/nginx.pid.oldbin`
查看已安装模块
/opt/nginx/sbin/nginx -V
--prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module
上传新的nginx.conf至/opt/nginx/conf
/opt/nginx/sbin/nginx -t
/opt/nginx/sbin/nginx -s reload
如果可以重启
/opt/nginx/sbin/nginx -t
/opt/nginx/sbin/nginx -s reload
/opt/nginx/sbin/nginx -s quit
#/opt/nginx/sbin/nginx -s stop
/opt/nginx/sbin/nginx &