To hot reload nginx configuartion without downtime (with graceful reload).
service nginx reload
Once the master process receives the signal to reload configuration, it checks the syntax validity of the new configuration file and tries to apply the configuration provided in it. If this is a success, the master process starts new worker processes and sends messages to old worker processes, requesting them to shut down. Otherwise, the master process rolls back the changes and continues to work with the old configuration. Old worker processes, receiving a command to shut down, stop accepting new connections and continue to service current requests until all such requests are serviced. After that, the old worker processes exit. --- Source
NOTE: I believe reload
is more graceful than restart
(If you perform service nginx restart
and there is a configuration error, nginx won't start again).
NOTE: You can run sudo nginx -t
to check for configuration error before restart/reload.