Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to nginx configuration updates without having to reload or restart nginx

Tags:

nginx

I want Nginx to update configuration file without reloading or restarting Nginx. It seem API or anything (http://nginx.com/products/on-the-fly-reconfiguration/).

like image 807
user3396381 Avatar asked Mar 08 '14 15:03

user3396381


People also ask

Do I need to restart nginx after config change?

You need to reload or restart Nginx whenever you make changes to its configuration. The reload command loads the new configuration, starts new worker processes with the new configuration, and gracefully shuts down old worker processes.

Does nginx auto reload config?

nginx -t will test the syntax of the configuration files and ensure that all configuration files referenced are accessible. If the Nginx configuration passes testing, then Nginx will be reloaded with nginx -s reload .

What is difference between reload and restart in nginx?

Restart vs Reload Nginx If Nginx notices a syntax error in any of the configuration files, the reload is aborted and the server keeps running based on old config files. Reloading is safer than restarting Nginx. The restart command will shut down the server including all related services and power it on again.


1 Answers

On Ubuntu or Debian it's as simple as using the reload argument:

service nginx reload

The official way is to send SIGHUP:

kill -HUP $(ps -ef | grep nginx | grep master | awk '{print $2}')

The above command will get the process ID of the nginx master process and send a SIGHUP signal to it.

See the Controlling Nginx documentation for Nginx.

You can also use the Nginx binary:

nginx -s reload
like image 73
Brandon Wamboldt Avatar answered Oct 22 '22 16:10

Brandon Wamboldt