Outils pour utilisateurs

Outils du site


systeme:compiler_nginx

Compiler Nginx avec libssl, libpcre et zlib en statique

  • Utilisez des versions à jour sur des vieux tromblons qui ne peuvent pas être mis à jour !
  • Fonctionne à partir d'Ubuntu 14.04
install-nginx_static-ssl-pcre-zlib
#!/bin/bash

# Compilation et installation de Nginx + OpenSSL/PCRE/ZLIB statiques

mkdir -p nginx-static
cd nginx-static

##################################################

NGINX_VERSION="1.19.6"
FAKE_NGINX_NAME="Fuck you W3 Server"
SSL_VERSION="1.1.1i"
PCRE_VERSION="8.44" 
ZLIB_VERSION="1.2.11"

OPTS="
 --with-threads
 --with-http_ssl_module
 --with-http_v2_module
 --with-http_stub_status_module
 --with-http_sub_module
 --with-http_auth_request_module
 --with-openssl=../openssl-${SSL_VERSION}
 --with-pcre=../pcre-${PCRE_VERSION}
 --with-zlib=../zlib-${ZLIB_VERSION}
 --with-http_gzip_static_module
 --add-module=../headers-more-nginx-module
"
 
##################################################
 
apt-get -y install build-essential git
 
##################################################
 
[ -d nginx ] || mkdir nginx
cd nginx
 
##################################################
 
[ -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

[ -f openssl-${SSL_VERSION}.tar.gz ] || wget "http://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz"
[ -d openssl-${SSL_VERSION} ] && rm -rf openssl-${SSL_VERSION}
tar -xzf openssl-${SSL_VERSION}.tar.gz
 
[ -f pcre-${PCRE_VERSION}.tar.gz ] || wget "https://ftp.pcre.org/pub/pcre/pcre-${PCRE_VERSION}.tar.gz"
[ -d pcre-${PCRE_VERSION} ] && rm -rf pcre-${PCRE_VERSION}
tar -xzf pcre-${PCRE_VERSION}.tar.gz
 
[ -f zlib-${ZLIB_VERSION}.tar.gz ] || wget "http://zlib.net/zlib-${ZLIB_VERSION}.tar.gz"
[ -d zlib-${ZLIB_VERSION} ] && rm -rf zlib-${ZLIB_VERSION}
tar -xzf zlib-${ZLIB_VERSION}.tar.gz

##################################################
 
cd nginx-${NGINX_VERSION}

sed -i "s/<center>nginx<\/center>/<center>${FAKE_NGINX_NAME}<\/center>/g" src/http/ngx_http_special_response.c

make clean  
 
./configure --prefix=/usr/local/nginx-static ${OPTS}
make -j $(( $(grep -c ^processor /proc/cpuinfo) + 1 ))  
 
[ $? -eq 0 ] || { echo "erreur compilation" ; exit 1 ; }

make install
 
##################################################

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-static/sbin/nginx"
DAEMON_OPTS="-c /etc/nginx/nginx.conf"
EOT

##################################################
 
service nginx start
 
cd ..
systeme/compiler_nginx.txt · Dernière modification: 01/03/2024 (modification externe)