1

How do I reload the nginx config file after editing it? I'm using this with Rails on a Mac... but I'm brand new to nginx so I really don't know how to do this. I've researched and tried nginx -s reload but that's just returning an error that there's no such file/directory.

nope2023
  • 1,668
  • 1
  • 15
  • 28
  • Possible duplicate of [Reload nginx configuration](https://stackoverflow.com/questions/21292533/reload-nginx-configuration) – Tomanow Aug 19 '17 at 10:57

2 Answers2

0

You can either restart nginx completely by something like systemctl restart nginx or /usr/local/etc/rc.d/nginx restart or you can send a signal to its process to make it reload its configuration: killall -s SIGHUP nginx

MaxC
  • 540
  • 5
  • 14
  • I've tried all three of those suggestions, the terminal returned: "No matching processes belonging to you were found"... "No such file or directory"... and "systemctl: command not found". Could it be a problem with the app? – nope2023 Oct 12 '16 at 22:30
  • No. From the tags you have used I see, that you are using OSX. I don't know how to restart services on OSX, but as it is more or less posix compatible chances are, that the signal solution works best. That said: If you don't have a killall-command try finding nginx PID with ps and send the signal using kill: "kill -s SIGHUP 1234" – MaxC Oct 12 '16 at 23:29
  • isn't the whole point of `-s reload` to avoid downtime between the transition? using `restart` or `killall` kind of defeats that purpose – Jivan Mar 23 '21 at 23:32
  • It is a common misunderstanding that killall can only be used to kill processes. Instead it can send signals, one of which is `SIGUSR1`, another is `SIGHUP`. None of these kill the process, but they can be handled by the running process and "do things". In case of `SIGHUP` it is reload, see here: http://nginx.org/en/docs/control.html and `SIGUSR1` is useful as well if you are using an external logrotate mechanism. – MaxC Mar 24 '21 at 16:27
-1

I do it like this

killall -9 nginx; sleep 1; nginx
Vasia Dunaev
  • 149
  • 1
  • 10
  • then you have at least a whole second of pure downtime, congratulations. Depending on what you're working on, that could cause a lot of problems. – Jivan Mar 23 '21 at 23:33