Ticket #1625: nginx_compile.sh

File nginx_compile.sh, 3.8 KB (added by Dryusdan@…, 8 years ago)

My script to compile nginx :)

Line 
1#!/bin/sh
2apt install zlib1g-dev zlib1g libpcre3 libpcre3-dev build-essential git wget
3
4NGINX_VER=1.15.3
5OPENSSL_VER=1.1.1-pre9
6NGINX_GPG="573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \
7 A09CD539B8BB8CBE96E82BDFABD4D3B3F5806B4D \
8 4C2C85E705DC730833990C38A9376139A524C53E \
9 65506C02EFC250F1B7A3D694ECF0E90B2C172083 \
10 B0F4253373F8F6F510D42178520A9993A1C052F8 \
11 7338973069ED3F443F4D37DFA64FD5B17ADB39A8"
12
13echo "**** download package ****"
14git clone https://github.com/openresty/headers-more-nginx-module --depth=1 /tmp/headers-more-nginx-module
15git clone https://github.com/bagder/libbrotli --depth=1 /tmp/libbrotli
16git clone https://github.com/google/ngx_brotli --depth=1 /tmp/ngx_brotli
17wget -q http://nginx.org/download/nginx-${NGINX_VER}.tar.gz -O /tmp/nginx-${NGINX_VER}.tar.gz
18wget -q http://nginx.org/download/nginx-${NGINX_VER}.tar.gz.asc -O /tmp/nginx-${NGINX_VER}.tar.gz.asc
19wget -q https://www.openssl.org/source/openssl-${OPENSSL_VER}.tar.gz -O /tmp/openssl-${OPENSSL_VER}.tar.gz
20git clone https://github.com/grahamedgecombe/nginx-ct --depth=1 /tmp/nginx-ct
21
22echo "**** compile brotli ****"
23cd /tmp/libbrotli
24./autogen.sh
25./configure
26mkdir brotli/c/tools/.deps
27touch brotli/c/tools/.deps/brotli-brotli.Po
28make -j 1
29make install
30cd /tmp/ngx_brotli
31git submodule update --init
32
33echo "**** untar openssl ****"
34cd /tmp
35tar xzf openssl-${OPENSSL_VER}.tar.gz
36
37echo "**** compile nginx ****"
38cd /tmp
39for server in ha.pool.sks-keyservers.net hkp://keyserver.ubuntu.com:80 hkp://p80.pool.sks-keyservers.net:80 pgp.mit.edu;
40 do
41 echo "Fetching GPG key $NGINX_GPGKEY from $server";
42 gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys $NGINX_GPG && found=yes && break;
43done
44gpg --batch --verify nginx-${NGINX_VER}.tar.gz.asc nginx-${NGINX_VER}.tar.gz
45tar xzf nginx-${NGINX_VER}.tar.gz
46cd /tmp/nginx-${NGINX_VER}
47wget -q https://raw.githubusercontent.com/cujanovic/nginx-dynamic-tls-records-patch/master/nginx__dynamic_tls_records_1.13.0%2B.patch -O dynamic_records.patch
48patch -p1 < dynamic_records.patch
49./configure --prefix=/etc/nginx \
50 --sbin-path=/usr/local/sbin/nginx \
51 --http-log-path=/var/log/nginx/logs/nginx_access.log \
52 --error-log-path=/var/log/nginx/logs/nginx_error.log \
53 --pid-path=/run/nginx.pid \
54 --lock-path=/run/nginx.lock \
55 --user=nginx --group=nginx \
56 --with-http_ssl_module \
57 --with-http_realip_module \
58 --with-http_addition_module \
59 --with-http_sub_module \
60 --with-http_dav_module \
61 --with-http_flv_module \
62 --with-http_mp4_module \
63 --with-http_gunzip_module \
64 --with-http_gzip_static_module \
65 --with-http_random_index_module \
66 --with-http_secure_link_module \
67 --with-http_stub_status_module \
68 --with-threads \
69 --with-stream \
70 --with-stream_ssl_module \
71 --with-http_slice_module \
72 --with-mail \
73 --with-pcre-jit \
74 --with-mail_ssl_module \
75 --with-http_v2_module \
76 --with-file-aio \
77 --with-ipv6 \
78 --add-module=/tmp/headers-more-nginx-module \
79 --add-module=/tmp/nginx-ct \
80 --add-module=/tmp/ngx_brotli \
81 --with-cc-opt="-O3 -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -Wno-deprecated-declarations" \
82 --with-openssl-opt='no-async enable-ec_nistp_64_gcc_128 no-shared no-ssl2 no-ssl3 no-comp no-idea no-weak-ssl-ciphers -DOPENSSL_NO_HEARTBEATS -O3 -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2' \
83 --with-openssl=/tmp/openssl-${OPENSSL_VER}
84make -j 1
85make install
86useradd --no-create-home nginx