Results 1 to 3 of 3

Thread: nginx not starting properly

  1. #1
    Join Date
    Dec 2008
    Beans
    79
    Distro
    Ubuntu

    start-stop-deamon user

    I'm not entirely sure where I'm messing up here, but essentially I'm trying to use the start/stop daemon to start up nginx by using the following line...

    Code:
    start-stop-daemon: user '/etc/nginx/nginx.conf' not found
    Command: start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid --group nginx --exec /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf -v
    As you can see from above, it's trying to pass the path to the config file as a user parameter. Now, what is confusing me here that this single line is essentially two...
    Code:
    # I think this tells the daemon to do a few things (set the group for the --exec, make a pid etc)
    start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid --group nginx --exec
    
    # This starts nginx and tell it which config to use, dumping a little verbose output
    /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf -v
    Anyone have any idea where I'm going wrong?
    Last edited by geudrik; March 24th, 2012 at 08:13 PM. Reason: Completely re-did my aproach
    Where there's a will, there's a way.

    Doing something fun in Linux? Stuck somewhere and bent on solving it yourself? Give Calomel some lovin' over here.

  2. #2
    Join Date
    Dec 2008
    Beans
    79
    Distro
    Ubuntu

    Re: nginx not starting properly

    As an update... when I run the following command..
    Code:
    $ sudo /etc/init.d/nginx --start
    Starting nginx...
    nginx version: nginx/1.0.14
    
    Failed to load nginx. Daemon *NOT* started.
    
    Command: --start --oknodo --pidfile /var/run/nginx.pid --startas /usr/local/nginx/sbin/nginx --chuid nginx -- -c /etc/nginx/nginx.conf -v
    When I run just
    Code:
    /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf -v
    it dumps out
    Code:
    Starting nginx...
    nginx version: nginx/1.0.14
    and promptly breaks, doesn't actually start or dump any other diagnostic information.

    But the server isn't actually running. In fact, in the init script that I wrote, it even tells me that starting the server failed. Any ideas?

    Edit: I'm using start-stop-daemon in my init script.
    Where there's a will, there's a way.

    Doing something fun in Linux? Stuck somewhere and bent on solving it yourself? Give Calomel some lovin' over here.

  3. #3
    Join Date
    Dec 2008
    Beans
    79
    Distro
    Ubuntu

    Re: nginx not starting properly

    Solved.

    Code:
    #! /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
    
    ## MAKE SURE YOUR BASE NGINX DIR IS LISTED HERE
    PATH=/usr/local/nginx:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    
    ## THIS IS THE ABSOLUTE PATH TO THE NGINX EXECUTABLE
    DAEMON=/usr/local/nginx/sbin/nginx
    
    ## Username you want nginx to run as
    NAME=nginx
    
    ## Process description you want to assign to nginx
    DESC=nginx
    
    ## Options to pass to nginx - manual config location (see then nginx wiki for more options)
    DAEMON_OPTS="-c /etc/nginx/nginx.conf"
    
    test -x $DAEMON || exit 0
    
    # Include nginx defaults if available
    if [ -f /etc/default/nginx ] ; then
        . /etc/default/nginx
    fi
    
    set -e
    
    . /lib/lsb/init-functions
    
    case "$1" in
      start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
            --exec $DAEMON -- $DAEMON_OPTS || true
        echo "$NAME."
        ;;
      stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
            --exec $DAEMON || true
        echo "$NAME."
        ;;
      restart|force-reload)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile \
            /usr/local/nginx/logs/$NAME.pid --exec $DAEMON || true
        sleep 1
        start-stop-daemon --start --quiet --pidfile \
            /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
        echo "$NAME."
        ;;
      reload)
          echo -n "Reloading $DESC configuration: "
          start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
              --exec $DAEMON || true
          echo "$NAME."
          ;;
      status)
          status_of_proc -p /usr/local/nginx/logs/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
          ;;
      *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
        exit 1
        ;;
    esac
    
    exit 0
    Where there's a will, there's a way.

    Doing something fun in Linux? Stuck somewhere and bent on solving it yourself? Give Calomel some lovin' over here.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •