Skip to content

Instantly share code, notes, and snippets.

@gemxx
Forked from cmbankester/homebrew.mxcl.nginx.plist
Created October 18, 2019 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gemxx/45efa0474a41590cf1a49576fcaf0a76 to your computer and use it in GitHub Desktop.
Save gemxx/45efa0474a41590cf1a49576fcaf0a76 to your computer and use it in GitHub Desktop.
NGINX startup on Mac OSX El Capitan
<?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>
<true/>
<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>

Install NGINX if it's not yet installed

brew install nginx

Add NGINX launcher to system launch daemons, runnable as root

sudo cp -v /usr/local/opt/nginx/*.plist /Library/LaunchDaemons
sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

Make sure launcher is set to keep nginx alive (see the example plist)

sudo vim /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
# Ensure this is in the file:
# <key>KeepAlive</key>
# <true/>

Launch NGINX

sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment