-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·124 lines (104 loc) · 3.33 KB
/
install.sh
File metadata and controls
executable file
·124 lines (104 loc) · 3.33 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env bash
set -e
##################
# VARS
##################
if [ -z $NGINX_VERSION ]
then
echo 'NGINX_VERSION is undefined'
exit 1
fi
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
vHEADERSMORE=${HEADERSMORE_VERSION:-"0.30"}
vNGINXFILTER=${FILTER_VERSION:-"0.6.4"}
vNGINXECHO=${ECHO_VERSION:-"0.59"}
vNGINXPAGESPEED=${NPS_VERSION:-"1.11.33.2"}
vUPSTREAM_PATCH=${UPSTREAM_PATCH_VERSION:-"1.11.5+"}
NGINXPKG="http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz"
NGINXHEADERSMORE="https://github.com/openresty/headers-more-nginx-module/archive/v${vHEADERSMORE}.tar.gz"
NGINXFILTER="https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/v${vNGINXFILTER}.tar.gz"
NGINXECHO="https://github.com/openresty/echo-nginx-module/archive/v${vNGINXECHO}.tar.gz"
NGINXUPSTREAM="https://github.com/yaoweibin/nginx_upstream_check_module.git"
NGINXPAGESPEED="https://github.com/pagespeed/ngx_pagespeed/archive/v${vNGINXPAGESPEED}-beta.tar.gz"
##################
# FCT
##################
function getPackage() {
echo "Get package $2 $1"
mkdir $2
curl -L# $1 | tar -zx --strip 1 -C $2
}
##################
# BEGIN
##################
cd
mkdir -p nginx_install && cd nginx_install
# Install pkgs
apt-get -qq update && \
apt-get -qq install -y \
curl build-essential libpcre3-dev libgeoip-dev libssl-dev \
git \
zlib1g-dev libpcre3 unzip
# Get nginx and prepare modules
getPackage $NGINXPKG nginx
getPackage $NGINXHEADERSMORE headersmore
getPackage $NGINXFILTER substitution
getPackage $NGINXECHO nginxecho
git clone $NGINXUPSTREAM `pwd`/nginxupstream
getPackage $NGINXPAGESPEED nginxpagespeed
cd nginxpagespeed
wget --quiet https://dl.google.com/dl/page-speed/psol/${vNGINXPAGESPEED}.tar.gz
tar -xzf ${vNGINXPAGESPEED}.tar.gz
cd ..
# Build
cd nginx
/usr/bin/patch -p0 < ../nginxupstream/check_${vUPSTREAM_PATCH}.patch && \
./configure --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2' \
--with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' \
--prefix=/usr/share/nginx \
--conf-path=/etc/nginx/nginx.conf \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--lock-path=/var/lock/nginx.lock \
--pid-path=/run/nginx.pid \
--with-debug \
--with-pcre-jit \
--with-ipv6 \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_auth_request_module \
--with-http_gzip_static_module \
--without-http_browser_module \
--without-http_geo_module \
--without-http_memcached_module \
--without-http_referer_module \
--without-http_scgi_module \
--without-http_split_clients_module \
--without-http_ssi_module \
--without-http_userid_module \
--without-http_uwsgi_module \
--add-module=../headersmore/ \
--add-module=../substitution/ \
--add-module=../nginxecho/ \
--add-module=../nginxupstream/ \
--add-module=../nginxpagespeed/ \
--with-http_flv_module \
--with-mail \
--with-http_geoip_module \
--with-http_v2_module && \
make && make install
STATUS=$?
if [ $STATUS -eq 0 ]
then
cp -r $DIR/nginx-install/geoip /etc/nginx/
cp $DIR/nginx-install/nginx-logrotate /etc/logrotate.d/nginx
mkdir -p /etc/nginx/conf.d
# Clean install directory
rm -rf $HOME/nginx_install
echo 'NGINX VERSION: ' && `/usr/share/nginx/sbin/nginx -v`
else
echo "Error... ($STATUS)"
exit $STATUS
fi
exit 0