Nginx Startup Script for Mac OS X
If you don't use MacPorts, and have a hard time finding a startup plist file for Nginx, and had trouble getting Nginx to startup with your custom plist file, this might be your solution:
<?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>nginx</string>
<key>Program</key>
<string>/usr/local/nginx/sbin/nginx</string>
<key>KeepAlive</key>
<true/>
<key>NetworkState</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
</dict>
</plist>
Just save this as /Library/LaunchDaemons/org.nginx.nginx.plist and perform the following in a bash session:
sudo chown root:wheel /Library/LaunchDaemons/org.nginx.nginx.plist
sudo launchctl load /Library/LaunchDaemons/org.nginx.nginx.plist
sudo launchctl start org.nginx.nginx
Comments
Mat
Example of brew plist for nginx 1.5: ------------------------------ Label org.nginx.nginx RunAtLoad KeepAlive UserName root ProgramArguments /usr/local/Cellar/nginx/1.0.5/sbin/nginx -g daemon off; WorkingDirectory /usr/local
Martin Stannard
Nice tip, thanks! One issue though, you spelt Daemons wrong a few times. Make copy/paste a bit confusing, cheers, Martin