'OSX - Start and Stopping of Nginx error
I install nginx via home brew and when i try to start or stop it i get the following error
➜ ~ sudo nginx -s stop
nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)
➜ ~ sudo nginx
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] still could not bind()
File structure
➜ ~ /usr/local/var/run
➜ run git:(master) ls
nginx
➜ run git:(master) cd nginx
➜ nginx git:(master) ls
client_body_temp fastcgi_temp proxy_temp scgi_temp uwsgi_temp
➜ nginx git:(master)
To check if nginx is running
➜ ~ ps waux | grep nginx
harshamv 963 0.0 0.0 2432772 656 s000 S+ 1:32PM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn nginx
When i try to run Nginx i get the following error.
➜ ~ nginx
nginx: [alert] could not open error log file: open() "/usr/local/var/log/nginx/error.log" failed (13: Permission denied)
2015/07/02 13:39:44 [emerg] 1074#0: open() "/usr/local/var/log/nginx/access.log" failed (13: Permission denied)
Solution 1:[1]
There is one case I have met. If you start nginx with a conf file, which looks like nginx -c my.conf, you have to stop it with nginx -s stop -c my.conf.
In your my.conf file, you may use pid /some_location/nginx.pid;, and this will generate a pid file at that location, which is not any more the default location at /usr/local/var/run/nginx.pid, and this is why you cannot stop it.
I think when you met such error, you have an option to check ps -ef | grep nginx for its pid, at least can kill it manually.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TonyTony |
