Después de instalar nginx con soporte para Pasajeros en '/ opt', ¿por qué no comenzará desde 'init.d'?


15

Revisé un tutorial http://craiccomputing.blogspot.com/2010/10/passenger-3-nginx-and-rvm-on-mac-os-x.html y todo estuvo bien. No hubo errores.

Nginx with Passenger support was successfully installed.

The Nginx configuration file (/opt/nginx/conf/nginx.conf)
must contain the correct configuration options in order for Phusion Passenger
to function correctly.

This installer has already modified the configuration file for you! The
following configuration snippet was inserted:

  http {
      ...
      passenger_root /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.14;
      passenger_ruby /home/alex/.rvm/wrappers/ruby-1.9.3-p194/ruby;
      ...
  }

After you start Nginx, you are ready to deploy any number of Ruby on Rails
applications on Nginx.

Sin embargo, no puedo comenzarlo.

alex@ubuntu:~$ sh -x /etc/init.d/nginx start
sh: 0: Can't open /etc/init.d/nginx

sudo /etc/init.d/nginx start
sudo: /etc/init.d/nginx: command not found

El directorio opt/nginxexiste y hay archivos en él. Localhost:80tampoco funciona

¿Alguna sugerencia?

Respuestas:


3

La forma normal de instalar nginx es a través de apt-get(o Synaptic o SW Center) y eso no incluye nada /opt, AFAIK. En ese caso, puede detenerlo / iniciarlo simplemente emitiendo:

sudo service nginx start|stop|restart (etc)

Si está nginxinstalado en sí mismo /opt, dudo que hubiera tocado el /etc/init.ddirectorio ...


1
Dice 'nginx: servicio no reconocido'
Alex Malex

1
sudo apt-get install nginx
ish

1
¿Por qué? anteriormente decía 'Nginx con soporte para pasajeros se instaló con éxito'.
Alex Malex

2
¿Estás siguiendo un tutorial para Mac , que dice claramente comenzar nginxdirectamente con sudoy parar killall, y luego preguntas por qué no está instalado como un servicio?
ish

2
Creo que OP pregunta por nginx + passenger, no por vanilla nginx.
user10962

20

La forma habitual de instalar una configuración Rails + NGINX + Passenger + RVM generalmente implica que nginx se coloque en / opt / nginx, pero de hecho no crea el archivo de inicio init.d. Esta publicación de blog muestra cómo puedes obtener fácilmente uno de Linode :

wget -O init-deb.sh https://www.linode.com/docs/assets/660-init-deb.sh
sudo mv init-deb.sh /etc/init.d/nginx
sudo chown root:root /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults

Para la posteridad, aquí está el guión de Linode:

#! /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=/opt/nginx/sbin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/nginx/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 /opt/nginx/logs/$NAME.pid \
                --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /opt/nginx/logs/$NAME.pid \
                --exec $DAEMON
        echo "$NAME."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile \
                /opt/nginx/logs/$NAME.pid --exec $DAEMON
        sleep 1
        start-stop-daemon --start --quiet --pidfile \
                /opt/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  reload)
          echo -n "Reloading $DESC configuration: "
          start-stop-daemon --stop --signal HUP --quiet --pidfile     /opt/nginx/logs/$NAME.pid \
              --exec $DAEMON
          echo "$NAME."
          ;;
      *)
            N=/etc/init.d/$NAME
            echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
            exit 1
            ;;
    esac

    exit 0

Una cosa a tener en cuenta: si ha cambiado su ubicación nginx.pid (el valor predeterminado es / opt / nginx / log, he cambiado el mío a / var / run), deberá cambiarlo en este archivo. Cerca de la parte superior, simplemente declararlo como una variable:

PIDPATH=/var/run/$NAME.pid

Y reemplace cualquier lugar que tenga la ruta al pid con $ PIDPATH. (Incluso si mantiene la ruta original, esto hace que el script sea más legible).


1

Recomiendo usar el Brightbox PPA mencionado en Brightbox Wiki . Esto permite la entrega de todos los servicios normales como service nginx starto /etc/init.d/nginx startfuera de la caja.

Esto funciona bien para mí en precisión (12.04 LTS).


1
Buen consejo. Nota: la URL del archivo init se ha movido permanentemente a https://www.linode.com/docs/assets/660-init-deb.sh.
Teemu Leisti
Al usar nuestro sitio, usted reconoce que ha leído y comprende nuestra Política de Cookies y Política de Privacidad.
Licensed under cc by-sa 3.0 with attribution required.