How to restart nginx on OS X How to restart nginx on OS X nginx nginx

How to restart nginx on OS X


Try running sudo nginx before starting nginx.


To reload config files:

sudo nginx -s reload

To fully restart nginx:

sudo nginx -s quitsudo nginx

Details

There is no restart signal for nginx. From the docs, here are the signals that the master process accepts:

SIGINT, SIGTERM  Shut down quickly.SIGHUP           Reload configuration, start the new worker process with a new configuration, and gracefully shut down old worker processes.SIGQUIT          Shut down gracefully.SIGUSR1          Reopen log files.SIGUSR2          Upgrade the nginx executable on the fly.SIGWINCH         Shut down worker processes gracefully.

Presumably you could send these signals to the process id manually, but the nginx command has the flag nginx -s <signal> that sends signals to the master process for you. Your options are:

stop    SIGTERMquit    SIGQUITreopen  SIGUSR1reload  SIGHUP

No need to futz with the pid manually.


Edit: just realized much of this info was already in comments on the other answers. Leaving this here anyway to summarize the situation.


What is your nginx pid file location? This is specified in the configuration file, default paths specified compile-time in the config script. You can search for it as such:

find / -name nginx.pid 2>/dev/null (must issue while nginx is running)

Solution:

sudo mkdir -p /usr/local/var/run/ln -s /current/path/to/pid/file /usr/local/var/run/nginx.pid