Outils pour utilisateurs

Outils du site


nginx:compiler_et_installer_nginx_a_partir_du_code_source

Compiler et installer Nginx à partir du code source

  • Installer la version «light» de Nginx pour mettre en place l'architecture de répertoires Debian:
apt-get install nginx-light
  • Créer le script install-nginx:
install-nginx
#!/bin/bash
 
NGINX_VERSION="1.9.12"
 
##################################################
 
apt-get install build-essential libpcre3-dev libssl-dev git
 
##################################################
 
[ -d nginx-1.9 ] || mkdir nginx-1.9
cd nginx-1.9
 
##################################################
 
[ -f nginx-${NGINX_VERSION}.tar.gz ] || wget "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz"
tar -xzf nginx-${NGINX_VERSION}.tar.gz
 
if [ -d headers-more-nginx-module ] ; then
        cd headers-more-nginx-module
        git pull https://github.com/openresty/headers-more-nginx-module.git
        cd ..
else
        git clone https://github.com/openresty/headers-more-nginx-module.git
fi
 
##################################################
 
cd nginx-${NGINX_VERSION}
 
make clean  
 
./configure --prefix=/usr/local/nginx --with-ipv6 --with-threads --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --add-module=../headers-more-nginx-module
# --with-stream\
# --with-stream_ssl_module\
# --with-http_dav_module\
# --with-http_image_filter_module\
# apt-get install libgd-dev => --with-http_image_filter_module
 
make -j $(( $(grep -c ^processor /proc/cpuinfo) + 1 ))  
 
[ $? -eq 0 ] || { echo "erreur compilation" ; exit 1 ; }
 
##################################################
 
service nginx stop
PIDS=$(ps awx |grep " nginx: " |grep -v grep |awk '{print $1}')
[ "${PIDS}" = "" ] || kill ${PIDS}
 
##################################################
 
grep -q "^DAEMON=" /etc/default/nginx || cat<<EOT>>/etc/default/nginx
DAEMON="/usr/local/nginx/sbin/nginx"
DAEMON_OPTS="-c /etc/nginx/nginx.conf"
EOT
 
make install && \
service nginx start
 
cd ..
  • Rendre le script exécutable:
chmod +x install-nginx
  • Exécuter le script (utilisateur root):
./install-nginx
  • Configurer Nginx
nginx/compiler_et_installer_nginx_a_partir_du_code_source.txt · Dernière modification: 15/03/2016 par laurent