Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

3 Answers 3

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
1  
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 wiki.nginx.org/Nginx-init-ubuntu 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:

#!/bin/bash
while [ 1 ]
  do /usr/local/sbin/nginx
done

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

DAEMON=/usr/local/sbin/nginx

with:

DAEMON=/usr/local/bin/loopnginx.sh
share|improve this answer

Your Answer

 
discard

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.