title: Nginx won't start. /usr/sbin/nginx and /var/run/nginx.pid don't exist
body: <p>I try to Nginx with <code>/etc/init.d/nginx start</code>. It exits with value 0 and otherwise does absolutely nothing because <code>/usr/sbin/nginx</code> doesn't exist.</p>
  
  <p>Here is <code>/etc/init.d/nginx</code>:</p>
  
  <pre><code>#!/bin/sh
  
  ### BEGIN INIT INFO
  # Provides:       nginx
  # Required-Start:    $local_fs $remote_fs $network $syslog $named
  # Required-Stop:     $local_fs $remote_fs $network $syslog $named
  # 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/sbin/nginx
  NAME=nginx
  DESC=nginx
  
  # Include nginx defaults if available
  if [ -r /etc/default/nginx ]; then
          . /etc/default/nginx
  fi
  
  test -x $DAEMON || exit 0
  
  set -e
  
  . /lib/lsb/init-functions
  
  # We made the awk expression more precise:
  # https://code.google.com/p/phusion-passenger/issues/detail?id=1060
  PID=$(awk -F'[ \t;]+' '/[^#]\&lt;pid/ {print $2}' /etc/nginx/nginx.conf)
  if [ -z "$PID" ]
  then
    PID=/var/run/nginx.pid
  fi
  
  # Check if the ULIMIT is set in /etc/default/nginx
  if [ -n "$ULIMIT" ]; then
    # Set the ulimits
    ulimit $ULIMIT
  fi
  
  test_nginx_config() {
                  $DAEMON -t $DAEMON_OPTS &gt;/dev/null 2&gt;&amp;1
                  retvar=$?
                  if [ $retvar -ne 0 ]
                  then
                          exit $retvar
                  fi
  }
  
  start() {
                  start-stop-daemon --start --quiet --pidfile $PID \
                          --retry 5 --exec $DAEMON --oknodo -- $DAEMON_OPTS
  }
  
  stop() {
                  start-stop-daemon --stop --quiet --pidfile $PID \
                          --retry 5 --oknodo --exec $DAEMON
  }
  
  case "$1" in
          start)
                  test_nginx_config
                  log_daemon_msg "Starting $DESC" "$NAME"
                  start
                  log_end_msg $?
                  ;;
  
          stop)
                  log_daemon_msg "Stopping $DESC" "$NAME"
                  stop
                  log_end_msg $?
                  ;;
  
          restart|force-reload)
                  test_nginx_config
                  log_daemon_msg "Restarting $DESC" "$NAME"
                  stop
                  sleep 1
                  start
                  log_end_msg $?
                  ;;
  
          reload)
                  test_nginx_config
                  log_daemon_msg "Reloading $DESC configuration" "$NAME"
                  start-stop-daemon --stop --signal HUP --quiet --pidfile $PID \
                          --oknodo --exec $DAEMON
                  log_end_msg $?
                  ;;
  
          configtest|testconfig)
                  log_daemon_msg "Testing $DESC configuration"
                  if test_nginx_config; then
                          log_daemon_msg "$NAME"
                  else
                          exit $?
                  fi
                  log_end_msg $?
                  ;;
  
          status)
                  status_of_proc -p $PID "$DAEMON" nginx
                  ;;
  
          *)
                  echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}" &gt;&amp;2
                  exit 1
                  ;;
  esac
  
  exit 0
  </code></pre>
  
  <p>I see that it exits with value 0 because of the <code>test -x $DAEMON || exit 0</code> line. If I comment that line out then the script will stop suddenly inside of the <code>test_nginx_config()</code> function when it goes to run the daemon (<code>/usr/sbin/nginx</code>) which doesn't exist. There is no <code>/usr/local/nginx/</code> directory either, for what it's worth.</p>
  
  <p>I'm a total newbie at this stuff so there might be something dumb simple going on but I just need to get this started up. Any help would be greatly appreciated.</p>