Search code examples
macosnginxrestart

How to restart nginx on OS X


I'm using nginx on OS X 10.8. Freshly installed nginx but can't find a way to restart nginx except kill nginx_pid say kill 64116. Wondering if there are better ways to restart nginx.

Found some methods on Google and SO but didn't work:

nginx -s restart

sudo fuser -k 80/tcp ; sudo /etc/init.d/nginx restart

The error message for nginx -s restart is

nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)

Sometimes also get this error msg:

nginx: invalid option: "-s restart"

Solution

  • 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