mac brew 启动服务时报错“Bootstrap failed: 5: Input/output error”

1.brew services start nginx时报错

➜  brew services start nginx
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/wangjianwen/Library/LaunchAgents/homebrew.mxcl.nginx.plist` exited with 5.

2.找到nginx应用程序目录,直接执行

直接执行程序目的是,看到更准确的报错提示,作出相应处理。

2.1进入到nginx的plist文件

获取到nginx的应用程序路径为:
/usr/local/opt/nginx/bin/nginx

vi ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>homebrew.mxcl.nginx</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/local/opt/nginx/bin/nginx</string>
                <string>-g</string>
                <string>daemon off;</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>WorkingDirectory</key>
        <string>/usr/local</string>
</dict>
</plist>

2.2 直接启动nginx

发现问题:nginx要用到的8080端口被占用

➜   /usr/local/opt/nginx/bin/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()

2.3 查看端口占用情况

lsof -i:8080
COMMAND    PID        USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
�\x81�  1376 wangjianwen   45u  IPv4 0xff7509a8126c8535      0t0  TCP bogon:53409->reverse.gdsz.cncnet.net:http-alt (ESTABLISHED)
�\x81�  1376 wangjianwen   63u  IPv4 0xff7509a811edcff5      0t0  TCP bogon:53618->157.255.245.177:http-alt (ESTABLISHED)
�\x81�  1376 wangjianwen   93u  IPv4 0xff7509a819bd5ff5      0t0  TCP bogon:53418->157.255.245.177:http-alt (ESTABLISHED)
java      1601 wangjianwen   44u  IPv6 0xff7509a81e1f135d      0t0  TCP *:http-alt (LISTEN)

2.4 kill掉所有占用8080端口的进程,然后重启nginx,启动成功

➜  brew services stop nginx
Stopping `nginx`... (might take a while)
==> Successfully stopped `nginx` (label: homebrew.mxcl.nginx)
➜  brew services start nginx
==> Successfully started `nginx` (label: homebrew.mxcl.nginx)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值