refer
1、修改了nginx配置后,在nginx的sbin目录下执行nginx -t,测试通过没有问题,
再执行nginx -s reload ,访问服务发现配置文件没有生效,
2、查看nginx进程
# ps -ef| grep nginx
root 251 0 0 07:35 ? 00:00:00 nginx: master process openresty
nobody 252 251 0 07:35 ? 00:00:02 nginx: worker process is shutting down
nobody 277 251 0 07:36 ? 00:00:02 nginx: worker process is shutting down
nobody 303 251 0 07:38 ? 00:00:02 nginx: worker process is shutting down
nobody 327 251 0 07:54 ? 00:00:01 nginx: worker process is shutting down
nobody 353 251 0 07:55 ? 00:00:00 nginx: worker process is shutting down
nobody 380 251 0 07:56 ? 00:00:00 nginx: worker process is shutting down
nobody 404 251 0 07:56 ? 00:00:01 nginx: worker process
root 427 17 0 08:04 pts/1 00:00:00 grep --color=auto nginx
发现很多shutting down
3、尝试重启nginx才生效,shutting down的进程也没了
nginx -s stop
nginx
原因分析:使用nginx -s reload 重启之后,旧的worker仍然会跑,新的请求会开新的worker,旧worker不再接受新链接,等所有连接结束后旧worker会退出,如果有长链接一直存在,那么将会一直用的是旧配置。