Nginx as a Linux Service

glen at lumanau.web.id glen at lumanau.web.id
Thu Oct 30 17:39:23 MSK 2008


i'm sure that he has installed nginx from source (.tar.gz). He isn't install in using rpm

Regards,

Glen Lumanau
-
Sent from my BlackBerry®

-----Original Message-----
From: "Jim Ohlstein" <jim.ohlstein at gmail.com>

Date: Thu, 30 Oct 2008 10:32:30 
To: <nginx at sysoev.ru>
Subject: RE: Nginx as a Linux Service


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: owner-nginx at sysoev.ru [mailto:owner-nginx at sysoev.ru] On Behalf Of Chris Gers32
Sent: Thursday, October 30, 2008 10:00 AM
To: nginx at 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,

Chris.
-- 
Posted via http://www.ruby-forum.com/.




More information about the nginx mailing list