3

I've just started with nginx in a MacOS Sierra v10.12.1.

After installed with Homebrew, the browser refuses me to connect with the message: This site can’t be reached. localhost refused to connect.

I've just then try to debug my nginx with nginx -t and it says that nginx.pid is missing:

nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: [emerg] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed

in addition, if I try to reload, it throws the following error:

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

Any idea of what's going on?

Thanks in advice.

DevStarlight
  • 784
  • 12
  • 29

1 Answers1

-1

It seems like Nginx has not started. Run below command (Correct the path based on your nginx daemon). It should be either

sudo /usr/local/nginx/sbin/nginx -s reload

or

sudo /usr/local/etc/nginx/sbin/nginx -s reload

Also find out the correct location of nginx.pid with below command

find / -name nginx.pid 2>/dev/null

Then update the path in your conf and then reload again using the first command.

Umar Hayat
  • 111
  • 1
  • 10
  • 1
    it seems that there's no sbin in my `/usr/local/nginx/` folder. About the `nginx.pid`, it finds it in the path `/usr/local/var/run/nginx.pid` but if I `ls -la`, it throws me this result: ` 25 Nov 8 17:21 nginx.pid -> /current/path/to/pid/file` ` – DevStarlight Nov 08 '16 at 21:00
  • It seems like installation issue. Can you run below command to find out if nginx sbin exisits on system on any path. – Umar Hayat Nov 08 '16 at 21:03
  • find / -name sbin 2>/dev/null – Umar Hayat Nov 08 '16 at 21:03
  • the response I get is: `/sbin /usr/local/sbin /usr/sbin` – DevStarlight Nov 08 '16 at 21:05
  • I found a similar discussion in detail for nginx on os x. Check this out if it helps http://stackoverflow.com/questions/14176477/how-to-restart-nginx-on-os-x – Umar Hayat Nov 08 '16 at 21:10
  • after following that other thread, I keep having issues, but referenced to this other error now: `nginx: [emerg] open() "/usr/local/var/run/nginx.pid" failed (62: Too many levels of symbolic links)`. When I `find / -name nginx.pid 2>/dev/null`, it points to `/usr/local/var/run/nginx.pid` – DevStarlight Nov 08 '16 at 21:27
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/127671/discussion-between-devstarlight-and-umar-hayat). – DevStarlight Nov 08 '16 at 21:33