准备文件:
# ^/ |9 u+ v% L: ] l& u: h1 Ywget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
( @8 v/ f% Y& g1 B- D/ X* jtar xvzf openssl-1.1.0f.tar.gz
! m% b8 B+ U# gwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz; w$ B4 x% }2 T4 B( F, B. w
tar xvzf pcre-8.41.tar.gz
& T% L& b W5 s+ ?, @& I; ~* Q" O
8 k* I( h! W1 ?9 g. g6 @+ |wget http://nginx.org/download/nginx-1.13.6.tar.gz, {7 i0 m1 E' Q8 K. N' q7 Q9 i
tart xvzf nginx-1.13.6.tar.gz O7 U% v& i5 O3 ^# ?+ M
8 s5 C$ Z; d% @+ i
wget https://github.com/openresty/sregex/archive/master.zip
( O; U. Y; w! T3 t$ A$ ]9 d. ?mv master.zip replace-filter-nginx-module-master.zip. [8 C) R' `* j- F% Q: C& Q6 z
unzip replace-filter-nginx-module-master.zip
8 i* l% M. f% w% Z4 Q
. }8 e# H+ Q, Y- `安装sregex
& n. x* s) U5 s/ N8 J[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]9 X2 l5 j' S0 s; F; M; `3 D. W# C
wget https://github.com/openresty/sregex/archive/master.zip2 R, e9 r' m! f2 a& N* X- ?# N
mv master.zip sregex.zip, W# X; |/ y' w" f4 B { V( W0 @! B, S
unzip sregex.zip
6 V* Z" F; @* p# ~cd sregex
/ H2 f5 k# R9 i+ _( Qmake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
9 A2 `1 Q7 f' \) [% q; P4 ~ldconfig
6 z0 M2 d& M$ U+ _. [1 \% L: ?( j, ~5 l+ H
安装modsecurity
, ]3 S; Q3 C& R9 ]. m$ Q, c『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』
0 h6 z6 z9 W- C- g* U) u9 V# Igit clone https://github.com/SpiderLabs/ModSecurity.git mod_security5 i9 u/ g9 q, J- g, q
cd mod_security! F, t$ m: v# N& [/ N) t, S3 w( W
./autogen.sh 5 T1 }) p3 e/ C; _0 [' |, X( @
./configure --enable-standalone-module
% G/ ?3 D) S8 omake5 D1 r4 K9 q4 K- I. z* i0 r
% ]3 R4 W5 M4 h6 W: g$ N, E% w5 j$ V9 o- W6 U0 X5 B( E
安装nginx
8 Q! m0 Y% x- {9 ]5 v) @7 L' ~cd nginx-1.13.6* Z9 i/ T3 W% O4 I
+ n, j$ v( K; f[Bash shell] 纯文本查看 复制代码 ./configure \
--user=www \
--group=www \
--prefix=/www/webserver/nginx-1.13.6 \
--sbin-path=/www/webserver/nginx-1.13.6/sbin/nginx \
--pid-path=/www/webserver/nginx-1.13.6/logs/nginx.pid \
--conf-path=/www/webserver/nginx-1.13.6/conf/nginx.conf \
--error-log-path=/www/webserver/nginx-1.13.6/logs/error.log \
--http-log-path=/www/webserver/nginx-1.13.6/logs/access.log \
--http-client-body-temp-path=/www/webserver/nginx-1.13.6/temp/client \
--http-proxy-temp-path=/www/webserver/nginx-1.13.6/temp/proxy \
--http-fastcgi-temp-path=/www/webserver/nginx-1.13.6/temp/fcgi \
--http-scgi-temp-path=/www/webserver/nginx-1.13.6/temp/scgi \
--http-uwsgi-temp-path=/www/webserver/nginx-1.13.6/temp/uwsgi \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_gzip_static_module \
--with-pcre=/root/pcre-8.41 \
--with-http_sub_module \
--add-module=/root/replace-filter-nginx-module-master \
--add-module=/root/mod_security/nginx/modsecurity \
--with-openssl=/root/openssl-1.1.0f 7 W' ^$ [, v- ~' h
make7 P1 N# s2 i# g; i; Y+ N# {! x
make install
3 W+ u: C( f8 Q6 {- P) U; `4 c' R) J* c
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
5 J/ E+ L% L% O6 [- u% a% g4 ?6 t: D2 _$ X& z+ a3 F) Y% T
% |' V- A# P0 k2 j
4 {# B3 G; M5 _0 A% x. C9 Y2 ?7 u. S
" Y; U8 \+ v* J: ^: O/ S! x
. T$ C/ M* j) ~( y0 [; _
% `6 r* }) {2 r8 y& W3 Q; F3 b/ h
( W$ ]" @8 k; x5 k( @ m- e" u/ R8 J
& z4 O0 i$ |& x; h |