准备文件:% s( _0 |; x' P4 a$ l! ?# _/ j
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz7 ^; k( o% S W: [* J
tar xvzf openssl-1.1.0f.tar.gz6 b% W% P8 ~1 n7 D% ]' ^
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz! P' Q& D9 w# }5 w. S8 W# O0 W! {
tar xvzf pcre-8.41.tar.gz
1 J0 j0 w# ~3 c! A8 u5 e; o, \5 u5 b3 Q% E$ P! ]8 @; `
wget http://nginx.org/download/nginx-1.13.6.tar.gz
|! H, M# c( N. rtart xvzf nginx-1.13.6.tar.gz [7 E1 [" X4 G( \% T. u9 J
" l4 T0 R$ E u" u/ L/ }/ {8 G* ewget https://github.com/openresty/sregex/archive/master.zip% S. k" f5 R5 ?5 s# l, y% c
mv master.zip replace-filter-nginx-module-master.zip5 l3 b0 H( ]. b* h, \
unzip replace-filter-nginx-module-master.zip
% o/ }( Z! N- g% L) G: T0 y. J
. w/ R/ ^: A) D9 p o安装sregex' r- s2 P" b& x( g8 m
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]% Y$ d6 w2 i9 j. L
wget https://github.com/openresty/sregex/archive/master.zip0 O" e5 I! z8 r& g2 ?0 O5 C6 M
mv master.zip sregex.zip: [7 b- c2 L( o9 A: P7 m( k& @' C/ r
unzip sregex.zip( h) Q4 {4 `* r$ w: k
cd sregex0 `( l" C" C6 N5 ] K
make && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
6 |( l" t; M" q2 yldconfig
7 ~% u. {" h# p, `' q1 s4 H4 F; f% @. @' `; v
安装modsecurity
$ X H) W% F+ O3 d) a『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』, ~1 n7 u8 z% i% u% B
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security
: W# A u; O5 _$ x# Q1 D% f$ c( Jcd mod_security6 a9 Q Q& q. ]7 W
./autogen.sh
$ C L( O" G$ M0 ?+ g! M ^./configure --enable-standalone-module: e3 Q! u% H2 Y
make6 [ S# o i+ Y" v; ~4 ^; P
6 K1 ?+ o; k Z2 _$ b8 s/ c
$ F; l. ^# Y0 }7 C! B# ]
安装nginx/ ]# I; D5 e9 n* u
cd nginx-1.13.6$ F- Z4 A- C: a8 k) G
8 i$ b" ]- K2 y0 l[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
# o$ r% j& B2 L% y# a+ Y9 Xmake8 [( j a5 y) p* _& w
make install
I, s z9 v9 S7 t
' a; M; R# g0 |' B( M% ^( m6 r注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
7 n# p7 T1 s( G+ @
6 M; E* u/ f* {" X- q/ A, E' n$ \* ~3 ]$ B6 J4 u- s% }5 A& c
5 c. S! W5 f G) Y9 g
" [* q2 d; p. D- O7 Q' j
$ }: [- }: I2 k6 l$ [( `
+ m; s$ ]* F! ~: i5 q* O$ a ]; J, ~
/ J) A/ ]3 [) d1 y8 w6 m
: @8 a6 R) c- ?2 z( e& O4 V
) T$ Q+ A* V- G4 I! g5 k |