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

vps*_*vps 91 nginx

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

小智 124

使用 nginx -s 重新加载

  • ^这个100%。发挥了魅力。 (5认同)

Raz*_*que 82

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
Run Code Online (Sandbox Code Playgroud)

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

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

  • 我更喜欢[下面的答案](https://serverfault.com/a/108750/561691)。 (2认同)

Sav*_*btz 23

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

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