我通过Homebrew安装了nginx
,但当我尝试启动或停止时出现以下错误:
➜ ~ 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()
文件结构
➜ ~ /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)
检查nginx是否正在运行
➜ ~ 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
当我尝试运行Nginx时,出现以下错误。
➜ ~ 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)
pgrep nginx
命令可以告诉您nginx是否仍在运行,而lsof -i 4tcp |grep 8080
命令则可以告诉您如果不是nginx,则哪个进程持有8080端口。 - Leonid Shevtsovsudo netstat -lnt | grep :8080
。 如果输出为空,则没有任何东西占用端口8080。您是否运行了上面建议的lsof
命令?如果 nginx 正在运行,则可以将其杀死,因为 pid 文件丢失,因此启动/停止脚本将无法停止它。 - alvitssudo netstat -lnt | grep :8080
和lsof -i 4tcp |grep 8080
时,它只是回到了命令提示符行。 - Harsha M V