Corks

Boot Script for Nginx on Ubuntu, Debian etc.

Couldn’t find a working startup script for nginx on Ubuntu, so I cobbled one together. This is principally based on the Lighttpd startup script and supports Start, Stop, Reload and friends. Works reliably on my Ubuntu Edge install, but should work on most other distros as well. Drop me a note if it worked on your distro, so I can update the comments.

If you custom-configured nginx, make sure to update the DAEMON (the binary) and CONFIG_FILE variables to reflect your settings.

Gist 33062

Update 12/10/07: Fixed extra space (Thanks, angelpopov)

5 comments

Knock on wood, this had something to do with and ?

Comments

fritzie

thanks for the script. i was wondering if anyone knows how to get the ssl passphrase to work with this. or should it be set somehow in the config file ?

angelpopov

the space should be removed in row
‘CONFIG_FILE =/usr/local/nginx/conf/nginx.conf’
the script works with
‘CONFIG_FILE=/usr/local/nginx/conf/nginx.conf

Achim

Nice script. Works fine for me … thank you

louis

thanks for the script. nicely done. works on Ubuntu 7.10 – but you knew that already. ;-) (ditto on the space between CONFIG_FILE and the ’=’, btw) in case fritzie is reading: the easiest way to bypass an ssl passphrase is to not have the key encrypted (so that the server doesn’t need a person to enter it). openldap needs it like this, and i’ve set up apache servers using this too. just keep the key in a private dir w/ no access except to the daemon.

Dan Dascalescu

The "stop" option doesn’t seem to kill the process on Ubuntu 8.04 Hardy: <pre>
/etc/init.d/nginx start
ps auxf
/etc/init.d/nginx stop
ps auxf | grep nginx # still running
<pre> Also, "reload" could be simplified by running just <code>kill -HUP `cat /usr/local/nginx/logs/nginx.pid`</code> as described at http://wiki.codemongers.com/NginxGettingStarted

Write a Comment

Optional. Will never be posted publicly.
A little bit of Magic is allowed. Please be nice and keep it pithy!
Oh Yoshimi, they don't believe me, but you won't let those robots defeat me!