准备文件:
: R! U5 d( S% H+ E+ J/ {% wwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
( U& W9 ]# `% {2 X+ h ttar xvzf openssl-1.1.0f.tar.gz0 S* g4 S' o: y5 u. A9 B" R
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
2 S5 c% a3 m- k Etar xvzf pcre-8.41.tar.gz# x- j/ Y3 U; H) r1 v8 e K
& O9 z& h0 h a
wget http://nginx.org/download/nginx-1.13.6.tar.gz
9 d; Q! Y% {! A( wtart xvzf nginx-1.13.6.tar.gz
I) W5 [$ H8 y6 F2 D, P* N q+ e" j; A
wget https://github.com/openresty/sregex/archive/master.zip+ X- q, |. z2 u) M. I8 E
mv master.zip replace-filter-nginx-module-master.zip
" l/ r& k/ I4 aunzip replace-filter-nginx-module-master.zip$ @0 ?% \" `- s
6 t; ]) J$ J7 o9 o# d5 d
安装sregex
- f) T& y% u5 m2 E[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]; P# M7 d: ~4 W K) t0 i0 V
wget https://github.com/openresty/sregex/archive/master.zip0 Z( C+ X0 c9 L ?$ n- s$ c
mv master.zip sregex.zip' n3 \; V1 O1 V6 F, J9 w' H
unzip sregex.zip7 }; A) w1 p& Q4 ~% \
cd sregex
$ q# H9 z! A+ S0 jmake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
Z9 C. |# ?* ]ldconfig, k7 r; E& r k# ^2 Z; e5 z- d5 o8 g
5 ^ ~6 ^5 @& O5 B8 {; L& m
安装modsecurity
+ |+ m$ U* l# s. _, B『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』* d* ]: E+ |& i6 @2 K
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security
H6 s2 Q+ D# @: F! ucd mod_security
- I5 F% w" a; n+ {1 J./autogen.sh
3 h% ~ h- }" e) \0 S2 j./configure --enable-standalone-module" R8 N- s! C. [* C+ A8 I
make; g1 y( G6 E5 ]2 ?0 Y
. z) x. ^% ~# |0 H& I: L' I. W
& Y& S* ?' h, C2 _% }安装nginx! {' t2 I, W) b' q6 I
cd nginx-1.13.6
2 x) n9 ^; x& X# w# J( U( O+ ^& ]7 X2 A" t1 j5 {( ?
[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
& u9 X( |. Y: @# S; @" E4 ?make
; P$ P2 b* L, O( A( ^$ U( t/ ^make install" W9 T7 `# p+ Z: E! D8 Q5 \0 W
' ^$ @9 m5 }% c( J
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
: L& w8 _: S2 [! |& y% i N6 s1 Y5 J# i+ P
! P; k2 ~: r3 R9 w |/ h# g o% j, p7 p7 x" i
9 u- l! q- a- j8 k+ b2 m& ]
& m) I# a* c: I# X C" Z1 N. ]5 S/ |2 L7 c2 b3 z# G
+ B& h/ B# D2 w& F( O; d. ]; O
0 m: G; m8 L5 U0 J8 u( ^/ S; W
|