atom feed28 messages in ru.sysoev.nginxRE: Nginx as a Linux Service
FromSent OnAttachments
Chris Gers32Oct 30, 2008 4:44 am 
Anoop AliasOct 30, 2008 4:58 am 
Chris Gers32Oct 30, 2008 6:59 am 
Cherife LiOct 30, 2008 7:17 am 
gl...@lumanau.web.idOct 30, 2008 7:21 am 
Eugene JanusovOct 30, 2008 7:28 am 
Jim OhlsteinOct 30, 2008 7:32 am 
Nick PearsonOct 30, 2008 7:34 am 
gl...@lumanau.web.idOct 30, 2008 7:39 am 
Eugene JanusovOct 30, 2008 7:49 am 
Chris Gers32Oct 30, 2008 8:23 am 
Eugene JanusovOct 30, 2008 8:59 am 
Robert GabrielOct 30, 2008 1:23 pm 
Chris Gers32Oct 31, 2008 3:42 am 
Robert GabrielOct 31, 2008 4:22 am 
Jim OhlsteinOct 31, 2008 5:38 am 
Chris Gers32Nov 17, 2008 6:15 am 
gl...@lumanau.web.idNov 17, 2008 6:23 am 
Chris Gers32Nov 17, 2008 7:13 am 
Jeremy HinegardnerNov 17, 2008 9:32 am 
Jim OhlsteinNov 17, 2008 10:04 am 
owkayeNov 18, 2008 12:36 am 
luben karavelovNov 18, 2008 1:31 am 
Chris Gers32Nov 21, 2008 1:47 am 
John MooreNov 21, 2008 3:03 am 
owkayeNov 21, 2008 4:03 am 
John MooreNov 21, 2008 4:39 am 
ThomasNov 21, 2008 6:29 am 
Subject:RE: Nginx as a Linux Service
From:Jim Ohlstein (jim.@gmail.com)
Date:Oct 30, 2008 7:32:07 am
List:ru.sysoev.nginx

Make sure that /etc/init.d/nginx is executable (chmod 755 will do it).

In RHEL:

chkconfig --add nginx

chkconfig --level 235 nginx-on

After that you can confirm with:

chkconfig --list

You should see nginx listed as "on" at those levels. You can run

/path/to/nginx -t

service nginx reload

to confirm.

If your script doesn't work, this is the one that I use:

#! /bin/sh

### BEGIN INIT INFO # Provides: nginx # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server # Description: starts nginx using start-stop-daemon ### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/sbin/nginx NAME=nginx DESC=nginx

test -x $DAEMON || exit 0

# Include nginx defaults if available if [ -f /etc/default/nginx ] ; then . /etc/default/nginx fi

set -e

case "$1" in start) echo -n "Starting $DESC: " start-stop-daemon --start --quiet --pidfile
/usr/local/nginx/logs/$NAME.pid \ --exec $DAEMON -- $DAEMON_OPTS echo "$NAME." ;; stop) echo -n "Stopping $DESC: " start-stop-daemon --stop --quiet --pidfile
/usr/local/nginx/logs/$NAME.pid \ --exec $DAEMON echo "$NAME." ;; restart|force-reload) echo -n "Restarting $DESC: " start-stop-daemon --stop --quiet --pidfile \ /usr/local/nginx/logs/$NAME.pid --exec $DAEMON sleep 1 start-stop-daemon --start --quiet --pidfile \ /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS echo "$NAME." ;; reload) echo -n "Reloading $DESC configuration: " start-stop-daemon --stop --signal HUP --quiet --pidfile
/usr/local/nginx/logs/$NAME.pid \ --exec $DAEMON echo "$NAME." ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac

exit 0

Hope that helps!

Jim

-----Original Message----- From: owne@sysoev.ru [mailto:owne@sysoev.ru] On Behalf Of Chris
Gers32 Sent: Thursday, October 30, 2008 10:00 AM To: ngi@sysoev.ru Subject: Re: Nginx as a Linux Service

Anoop Alias wrote:

Yes , Of-course :)

When you install nginx you will get a startup script /etc/init.d/nginx

Thank your for your quick reply. So I first created a symbolic link from /etc/init.d/nginx to /usr/local/nginx/sbin/nginx then rebooted, but nginx didn't start. So I replaced the symbolic link with a copy of the nginx executable, again to no avail...

You can tell I'm not a Linux expert, but what am I missing?

Thanks,