GNU/Linux >> Tutoriales Linux >  >> Debian

Cómo compilar desde la fuente e instalar Nginx en un VPS Debian 7 (Wheezy)

El siguiente artículo trata sobre cómo compilar e instalar el servidor HTTP ultrarrápido conocido como Nginx.

Entonces, ¿qué es exactamente Nginx?

Es un servidor HTTP ligero, gratuito, de código abierto y de alto rendimiento que, a diferencia de la mayoría de los otros servidores HTTP, no se basa en el manejo de subprocesos de las solicitudes, sino que utiliza una arquitectura basada en eventos (asincrónica) mucho más escalable y robusta.

Esto utiliza una cantidad de memoria muy pequeña y predecible bajo una carga pesada.

De todos modos, si está buscando instrucciones sobre cómo configurar e instalar Nginx, PHP-FPM y MySQL (LNMP Stack) en Debian 6 (Squeeze), lea nuestro artículo sobre cómo instalar y configurar LEMP (Nginx, MySQL y PHP) en un VPS Debian 6 (squeeze)

Para este tutorial estamos usando uno de nuestros servidores virtuales Debian. Bien, lo primero que debe hacer es asegurarse de que nuestro sistema Debian 7 (Wheezy) esté actualizado:

# apt-get update
# apt-get upgrade
# apt-get dist-upgrade

A continuación, instale algunos paquetes necesarios para que podamos construir nuestro Nginx:

# apt-get install build-essential
# apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev

Continúe con la descarga y extracción de las fuentes de Nginx desde http://nginx.org/en/download.html

# mkdir ~/sources
# cd ~/sources/
# wget http://nginx.org/download/nginx-1.4.0.tar.gz
# tar zxf nginx-1.4.0.tar.gz
# cd nginx-1.4.0

ejecute el script 'configure' para configurar las fuentes. consulte `./configure –help` para obtener más información sobre lo que puede usar.

# ./configure \
--prefix=/usr \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_ssl_module \
--user=www-data \
--group=www-data \
    --with-http_stub_status_module \
--with-http_gzip_static_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module

continúe con la compilación e instalación de Nginx:

# make
# make install

una vez completada la instalación, agregue el siguiente script de inicio a /etc/init.d/nginx para que pueda administrar su instalación de 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/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

. /lib/lsb/init-functions

case "$1" in
  start)
    echo -n "Starting $DESC: "
    start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
        --exec $DAEMON -- $DAEMON_OPTS || true
    echo "$NAME."
    ;;
  stop)
    echo -n "Stopping $DESC: "
    start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
        --exec $DAEMON || true
    echo "$NAME."
    ;;
  restart|force-reload)
    echo -n "Restarting $DESC: "
    start-stop-daemon --stop --quiet --pidfile \
        /var/run/$NAME.pid --exec $DAEMON || true
    sleep 1
    start-stop-daemon --start --quiet --pidfile \
        /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
    echo "$NAME."
    ;;
  reload)
      echo -n "Reloading $DESC configuration: "
      start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
          --exec $DAEMON || true
      echo "$NAME."
      ;;
  status)
      status_of_proc -p /var/run/$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

haga que el script de inicio sea ejecutable y agregue Nginx a las aplicaciones de inicio de su sistema:

# chmod +x /etc/init.d/nginx
# update-rc.d -f nginx defaults

configurar Nginx:

# mkdir /etc/nginx/{sites-available,sites-enabled}

en /etc/nginx/nginx.conf agregue lo siguiente:

user  www-data;
worker_processes  2;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/sites-enabled/*;
}

agregue el bloque de servidor en /etc/nginx/sites-disponible/example.com (asegúrese de cambiar cualquier ocurrencia de example.com con su dominio deseado).

server {
    listen       80;
    server_name  example.com;

    location / {
        root   /var/www/example.com;
        index  index.html index.htm;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

}

habilite el bloque de servidor que acaba de agregar:

# cd /etc/nginx/sites-enabled/
# ln -s /etc/nginx/sites-available/example.com

reinicie su Nginx usando:

# service nginx restart

agregue una página de muestra y pruebe su Nginx abriendo su dominio que usó en el bloque del servidor.

# mkdir -p /var/www/example.com

# echo -e "<html>\n<head><title>NGINX</title></head>\n \
<body>\t<h1>Powered by RoseHosting.com</h1>\n</body>\n</html>" \
> /var/www/example.com/index.html

Por supuesto, no tiene que hacer nada de esto si utiliza uno de nuestros servicios de alojamiento VPS de Linux, en cuyo caso simplemente puede pedirle a nuestros administradores expertos de Linux que lo instalen por usted. Están disponibles las 24 horas del día, los 7 días de la semana y atenderán su solicitud de inmediato.

PD. Si te gustó esta publicación, compártela con tus amigos en las redes sociales usando los botones de la izquierda o simplemente deja una respuesta a continuación. Gracias.


Debian
  1. Cómo instalar Gitlab, Ruby y Nginx en un VPS Debian 7 (Wheezy)

  2. Cómo instalar Plone 4 CMS en Debian Wheezy con Nginx

  3. Cómo instalar Chive en un VPS Debian Wheezy

  4. Cómo instalar DokuWiki en Debian Wheezy con Nginx

  5. Cómo instalar Microweber en Debian 9

Cómo instalar Nginx en Debian 9

Cómo construir Nginx desde la fuente en Debian 9

Cómo instalar Nginx en Debian 11

Cómo instalar Nginx y PHP en Debian 10

Cómo instalar Wine en Debian 7 Wheezy

Cómo instalar Nginx en Debian 10