如何在不重启nginx的情况下让修改生效?

如何在不重启nginx的情况下让修改生效?

Apache 有一个graceful选项可以在http.conf不重新启动 Apache 的情况下扫描修改。那么 nginx 呢?

答案1

nginx 支持以下信号:

TERM, INT - Quick shutdown
QUIT - Graceful shutdown
HUP - Configuration reload: Start the new worker processes with a new configuration, Gracefully shutdown the old worker processes
USR1 - Reopen the log files
USR2 - Upgrade Executable on the fly
WINCH - Gracefully shutdown the worker processes

HUP 就是你要找的,所以sudo kill -HUP pid (nginx pid)

来源 : http://nginx.org/en/docs/control.html

答案2

使用 nginx -s reload

答案3

通常nginx的init-script会有reload动作,即:

  • Linux/etc/init.d/nginx reload
  • FreeBSD/usr/local/etc/rc.d/nginx reload

答案4

不久前,我写了一篇关于如何在零停机时间内重启 nginx 的文章。这篇文章可能对你有帮助。

http://tumblelog.jauderho.com/post/101514948/restart-nginx-with-zero-downtime

相关内容