Gabriel Tong
Gabriel Tong

Reputation: 216

how do I restart nginx which is install by passenger

I installed nginx by passenger-install-nginx-module , and start nginx by /opt/nginx/sbin/nginx, but I don't know how to stop or restart nginx after I update my nginx conf.

I know I can use the way ps aux | grep and kill, it there a way like services restart nginx ?

Upvotes: 2

Views: 1888

Answers (1)

grochmal
grochmal

Reputation: 3027

nginx is build to reload configuration without the need for a restart. The common way to restart nginx is to first do

nginx -t

Which will analyse the configuration file and tell you if there are any problems (this is very convenient since syntax errors in the configuration file means downtime). And then

nginx -s reload

Will reload the configuration and restart nginx workers one by one with the new config. This simply finds the master nginx process and sends it the right signal (this is not much different from your ps axu | grep and kill, it just uses a different signal).

There are several other useful command line options for configuration and logging. Being aware of them lets you run nginx practically without any downtime.

Upvotes: 3

Related Questions