gpt4 book ai didi

macos - OSX - 启动和停止 Nginx 错误

转载 作者:行者123 更新时间:2023-12-04 15:49:51 30 4
gpt4 key购买 nike

我通过 home brew 安装 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)

最佳答案

我遇到过一个案例。如果你用一个 conf 文件启动 nginx,它看起来像 nginx -c my.conf,你必须用 nginx -s stop -c my.conf 停止它。

在你的my.conf文件中,你可以使用pid/some_location/nginx.pid;,这会在那个位置生成一个pid文件,这不是默认位置不再是 /usr/local/var/run/nginx.pid,这就是您无法停止它的原因。

我想当你遇到这样的错误时,你可以选择检查 ps -ef | grep nginx 获取它的pid,至少可以手动杀掉它。

关于macos - OSX - 启动和停止 Nginx 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31178467/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com