forked from fancyremarker/docker-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-nginx
executable file
·94 lines (74 loc) · 3.1 KB
/
install-nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
set -o nounset
set -o errexit
set -o pipefail
mkdir /nginx && cd /nginx
NGINX_VERSION='1.19.1'
NGINX_SHASUM='3cd394aab6a9320186417457531c5e565b4e0829'
NGINX_RESOURCE="nginx-${NGINX_VERSION}"
NGINX_ARCHIVE="${NGINX_RESOURCE}.tar.gz"
NGX_DEVEL_KIT_VERSION="0.3.1"
NGX_DEVEL_KIT_SHASUM="e15316e13a7b19a3d2502becbb26043a464a135a"
NGX_DEVEL_KIT_RESOURCE="ngx_devel_kit-${NGX_DEVEL_KIT_VERSION}"
NGX_DEVEL_KIT_ARCHIVE="${NGX_DEVEL_KIT_RESOURCE}.tar.gz"
NGX_LUA_VERSION="0.10.15"
NGX_LUA_SHASUM="d09f8353ca573ae6a4b33af252433197d6e45b13"
NGX_LUA_RESOURCE="lua-nginx-module-${NGX_LUA_VERSION}"
NGX_LUA_ARCHIVE="${NGX_LUA_RESOURCE}.tar.gz"
HEADERS_MORE_VERSION="0.33"
HEADERS_MORE_SHASUM="7d6af910dae98f0dbc67bf77e82eab8b7da5d0b1"
HEADERS_MORE_RESOURCE="headers-more-nginx-module-${HEADERS_MORE_VERSION}"
HEADERS_MORE_ARCHIVE="${HEADERS_MORE_RESOURCE}.tar.gz"
BUILD_DIR="$(mktemp -d)"
cd "$BUILD_DIR"
curl -fsSL "http://nginx.org/download/${NGINX_ARCHIVE}" -o "$NGINX_ARCHIVE"
echo "${NGINX_SHASUM} ${NGINX_ARCHIVE}" | sha1sum -c -
tar zxf "$NGINX_ARCHIVE"
curl -fsSL "https://github.com/simplresty/ngx_devel_kit/archive/v${NGX_DEVEL_KIT_VERSION}.tar.gz" -o "$NGX_DEVEL_KIT_ARCHIVE"
echo "${NGX_DEVEL_KIT_SHASUM} ${NGX_DEVEL_KIT_ARCHIVE}" | sha1sum -c -
tar zxf "$NGX_DEVEL_KIT_ARCHIVE"
curl -fsSL "https://github.com/openresty/lua-nginx-module/archive/v${NGX_LUA_VERSION}.tar.gz" -o "$NGX_LUA_ARCHIVE"
echo "${NGX_LUA_SHASUM} ${NGX_LUA_ARCHIVE}" | sha1sum -c -
tar zxf "$NGX_LUA_ARCHIVE"
curl -fsSL "https://github.com/openresty/headers-more-nginx-module/archive/v${HEADERS_MORE_VERSION}.tar.gz" -o "$HEADERS_MORE_ARCHIVE"
sha1sum "${HEADERS_MORE_ARCHIVE}"
echo "${HEADERS_MORE_SHASUM} ${HEADERS_MORE_ARCHIVE}" | sha1sum -c -
tar zfx "$HEADERS_MORE_ARCHIVE"
echo "Downloaded:"
ls -l
cd "$NGINX_RESOURCE"
# Cribbing from
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx/APKBUILD
# but adding --with-http_realip_module to support "set_real_ip_from" directive
# and removing some options which we may not need.
apk-install build-base pcre pcre-dev openssl openssl-dev zlib zlib-dev luajit luajit-dev
export LUAJIT_LIB=/usr/lib
export LUAJIT_INC=/usr/include/luajit-2.1
mkdir -p /tmp/nginx
./configure \
--prefix=/usr \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/tmp/nginx/client-body \
--http-proxy-temp-path=/tmp/nginx/proxy \
--http-fastcgi-temp-path=/tmp/nginx/fastcgi \
--user=nginx \
--group=nginx \
--with-pcre-jit \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--add-module="../${NGX_DEVEL_KIT_RESOURCE}" \
--add-module="../${NGX_LUA_RESOURCE}" \
--add-module="../${HEADERS_MORE_RESOURCE}"
make
make install
apk del build-base openssl-dev pcre-dev zlib-dev
# Create the user and group under which the nginx process will run.
addgroup -S nginx 2>/dev/null || true
adduser -G nginx -H -s /sbin/nologin -D nginx 2>/dev/null || true
# Finally, clean everything up
rm -rf "$BUILD_DIR"