Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can someone help me to setup nginx on my box? I have compiled it (i'm using it to run Django app using uwsgi_rs).

Its running OK but i have to start it manually. How can i setup it to autorun? And start it again (automatically) if it ware killed? I'm talking about nginx and uwsgi...

share|improve this question
up vote 0 down vote accepted

You can find an Ubuntu 9 compatible init script for nginx on the nginx wiki. It also contains instructions on how to install it so that it is started when the system boots.

share|improve this answer
I suspect the "right" answer here might be to write an Upstart script. – Tom O'Connor Mar 21 '11 at 10:31
Does Upstart can restart nginx process? If it were killed? I saw script but i'm not sure it support auto-restarting... Am I wrong? – NilColor Mar 21 '11 at 11:41

I would suggest to take a look at runit. I've grown quite fond of it. There are packages for it on most distributions and the setup is not that hard.

share|improve this answer

I don't know about the capabilities of nginx, so I just assume you've checked (man nginx) that it doesn't have an option to automatically respawn. You can create (as root) a simple script like this:

while [ 1 ]
  do /usr/local/sbin/nginx

save as, for example, /usr/local/bin/, then do chmod +x /usr/local/bin/ and finally, in the init script you mentioned, replace the line



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.