Nginx, help needed

Discussion in 'Nginx' started by AndiV74, Jul 11, 2009.

  1. #1
    Hello,

    I've tried a serveral times to start nginx but it always ends with no happy end.

    Download and compiling is no problem for me.

    So here goes my way that i do it:

    1) cd /tmp
       wget wget http://sysoev.ru/nginx/nginx-0.7.61.tar.gz
       tar xvfz nginx-0.7.61.tar.gz
       cd nginx-0.7.61
       
    ./configure \
      --prefix=/usr \
      --conf-path=/etc/nginx/nginx.conf \
      --http-log-path=/var/log/nginx/access_log \
      --error-log-path=/var/log/nginx/error_log \
      --pid-path=/var/run/nginx.pid \
      --http-client-body-temp-path=/var/tmp/nginx/client \
      --http-proxy-temp-path=/var/tmp/nginx/proxy \
      --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
      --with-md5-asm --with-md5=/usr/include \
      --with-http_realip_module \
      --with-http_ssl_module \
      --with-http_stub_status_module
    
       make
       make install
    
    2) vi /etc/init.d/nginx
    
    
    #! /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/nginx.pid --exec $DAEMON -- $DAEMON_OPTS
            echo "$NAME."
            ;;
      stop)
            echo -n "Stopping $DESC: "
            start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/nginx.pid --exec $DAEMON
            echo "$NAME."
            ;;
      restart|force-reload)
            echo -n "Restarting $DESC: "
            start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/nginx.pid --exec $DAEMON
            sleep 1
            start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/nginx.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/nginx.pid --exec $DAEMON
          echo "$NAME."
          ;;
      *)
            N=/etc/init.d/$NAME
            echo "Usage: $N {start|stop|restart|force-reload}" >&2
            exit 1
            ;;
    esac
    
    exit 0
    
    3) chmod 755 /etc/init.d/nginx
    
    4) /etc/init.d/nginx start
    Code (markup):
    But it won't start because of this error here:

    (root)-(/tmp/nginx-0.7.61) $ /etc/init.d/nginx start
    /etc/init.d/nginx: line 1: N: command not found
    Code (markup):
    So help would be great :D
     
    AndiV74, Jul 11, 2009 IP
  2. st1905

    st1905 Well-Known Member

    Messages:
    573
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    135
    #2
    dos2unix /etc/init.d/nginx

    Then try to restart it.
     
    st1905, Jul 15, 2009 IP
  3. vasyl

    vasyl Peon

    Messages:
    138
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    check that th 1st line in /etc/init.d/nginx is #!/bin/sh and no ^M on the end of each line
     
    vasyl, Jul 15, 2009 IP