启动时没有在启动时加载nginx

jwe*_*rre 3 homebrew nginx launchd plist

我用自制软件安装了NGINX然后我得到了信息并按照说明加载了launchd plist

$ brew info nginx
nginx: stable 1.6.2, devel 1.7.7, HEAD
...
To load nginx:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Or, if you don't want/need launchctl, you can just run:
    nginx
Run Code Online (Sandbox Code Playgroud)

问题是我重启时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>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <false/>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/opt/nginx/bin/nginx</string>
        <string>-g</string>
        <string>daemon off;</string>
    </array>
    <key>WorkingDirectory</key>
    <string>/usr/local</string>
  </dict>
</plist>                                                                                                                                                                                                                                                
Run Code Online (Sandbox Code Playgroud)

jwe*_*rre 10

这对我有用:

sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
Run Code Online (Sandbox Code Playgroud)

这方面的诀窍是Mac OSX不会让"root"或"system"级服务以外的任何东西使用低于1024的端口号.

在这里阅读更多内容:http://derickbailey.com/2014/12/27/how-to-start-nginx-on-port-80-at-mac-osx-boot-up-log-in/