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)

你可能感兴趣的:(问题处理,macos,nginx,brew)