Hunter Ford Hunter Ford

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