准备文件:
0 i" i# f) o2 b9 p) | Y n9 z5 |$ vwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz5 [' d4 b4 f9 s V( n
tar xvzf openssl-1.1.0f.tar.gz# G V8 Z3 s) W5 f9 p! {/ K
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz$ W. B/ G! F% \- I- A+ V6 G% q
tar xvzf pcre-8.41.tar.gz5 P; U3 ~) d" V% B% X
4 Z5 U9 h/ C0 T! o
wget http://nginx.org/download/nginx-1.13.6.tar.gz
0 t' A% M. ^% u. e+ _tart xvzf nginx-1.13.6.tar.gz E" ?) K6 D0 n8 n5 Q# C j1 A
2 Z- l, L' n$ c. d
wget https://github.com/openresty/sregex/archive/master.zip
9 g3 S8 O) D" @( h5 C( J' W6 Fmv master.zip replace-filter-nginx-module-master.zip
3 b6 `0 u2 G' {unzip replace-filter-nginx-module-master.zip
7 D7 l" M) T/ {2 @4 o& j
2 l( i6 k! }3 w! e安装sregex( R/ I+ A- q' `
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]
M8 y f' M% W; Y) M/ f6 Z) C0 Zwget https://github.com/openresty/sregex/archive/master.zip5 Y% o5 o P$ G
mv master.zip sregex.zip
4 ? b/ l" U* Cunzip sregex.zip( l' C( O/ j; r3 \# _- V
cd sregex, L/ _+ T& N* z' d* Y: C
make && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整' R( d# T2 Z8 Y& ~7 a
ldconfig5 m3 r7 I6 [" `% s [8 G; O
% x; x9 I" e* J安装modsecurity
, \. @5 M0 Q: j, c8 Z" T. F『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』
( ^7 W, P5 }0 g" Fgit clone https://github.com/SpiderLabs/ModSecurity.git mod_security
5 c5 G4 f( p+ r8 w& ucd mod_security4 e3 y. S$ S* r6 R/ g: G: l# \
./autogen.sh 3 T' E8 g1 w8 l1 h# ~2 Q) F7 N1 w
./configure --enable-standalone-module
* J/ h- O0 G- |* d# Zmake; J w+ n9 ~% b1 K/ q; M
4 b7 X+ m% |0 y7 J. o5 v
) y+ |6 \" I4 P' Q: y1 H/ s
安装nginx0 R1 W2 D% x; i, f
cd nginx-1.13.63 n5 u% n, m* B+ ~& z7 j# Y
0 m4 i0 q: Y: t* N% |* Y[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
: L4 y) n( w6 a7 \. B0 wmake
: P7 K* w) ?2 I- m+ k w2 Amake install
* O( N/ T( D: m4 X) O# J. O9 w1 g: _9 ]6 B9 z7 U8 S
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
( u" @. a4 u; m0 z, K: I
( z- d0 k$ d1 y3 ^
; ?! Z8 X" K5 ^+ R: Z. r
8 S7 U+ H; F/ @! {7 g9 C0 `6 G0 E, U
. Q; l& R4 T$ m9 f2 v6 I1 X: C X7 v) q) d N. h6 c
2 P/ M0 |& m4 H; h, k% D! x
! a# ?" K5 W9 a9 L: Z, y
' K' O" o6 z$ I, D3 |" p& o' Y |