准备文件:
! h1 ~, M1 o. Fwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
' V6 u8 j; V: c( s; Ttar xvzf openssl-1.1.0f.tar.gz
; G! X% c, F& c: |1 a0 qwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz; F) }% Y2 V2 y% O6 Y; r0 h
tar xvzf pcre-8.41.tar.gz5 v$ q/ e0 d! M6 L. d& F
) ^* h1 y$ D6 t B$ q: t: N
wget http://nginx.org/download/nginx-1.13.6.tar.gz) L8 I3 t! o2 }1 I6 ~+ H6 F
tart xvzf nginx-1.13.6.tar.gz' ]& a8 k/ r% A7 ]2 N3 O
# q+ B. W1 {8 m7 o
wget https://github.com/openresty/sregex/archive/master.zip
4 z1 K. c1 `- h6 tmv master.zip replace-filter-nginx-module-master.zip
- Z) M; |2 Z6 y0 o4 F/ x+ ~4 Bunzip replace-filter-nginx-module-master.zip; p9 [6 J# l( [3 H+ \
$ K* A! L; V3 }; j
安装sregex' Y0 K! u4 l% _4 X+ X. q9 ]
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]
) u- X: V* ^0 y7 z7 f- E. c6 {wget https://github.com/openresty/sregex/archive/master.zip: Q! _, M# J( |6 L8 Q
mv master.zip sregex.zip
3 ~ U0 c2 _/ `, g( P3 ]6 ?6 cunzip sregex.zip8 \0 \) T" O# I: o2 s q5 Z
cd sregex
4 C, l9 m7 a3 d8 h3 zmake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
; y8 F3 }1 G6 E" V: P* u# yldconfig
% b5 s3 `8 X1 J) Y H( g1 L
7 c! L8 ], i7 G0 ?) V安装modsecurity0 O$ |0 u) c3 z- s _
『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』# r7 R* D, G1 W/ v5 R4 H1 Y8 r
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security
3 |3 j+ U. t5 Tcd mod_security' |. C8 f3 p3 `5 R
./autogen.sh
3 a j3 z) R; A1 g( g./configure --enable-standalone-module: s1 _; K+ Q2 f4 F* W8 X. F
make
1 ?( ?7 ?2 n2 j- E" B; Q$ i
, ]0 X3 M. g, C9 F! M% }/ M% c5 { n/ }4 Z+ }, k7 _6 Z0 P( z
安装nginx5 l& ]1 t3 [ y: k
cd nginx-1.13.6- F/ g+ P7 G( y7 D3 g2 c
0 U8 }* @# w: v5 \- p5 N( Q
[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 9 s( f/ a1 K d# M. A
make- n; C J: j9 ^
make install
3 W: ?$ T" Q- b, c4 Q" K+ C$ N; g( | \9 e0 z: W
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module9 q+ C1 u* o6 k2 b* S4 g
* b4 B% P& G. V$ C' O
) e5 O4 X- j! v5 c: V/ I3 p
1 N/ W7 d$ z) j" {' q
4 o# P6 o5 j5 q# n
; c. n& H" {, R+ {! }7 V
" f! ?, n( Y! w0 z
8 I( |, O# z8 S* e! y$ I. c( E0 y/ J( s8 J Y$ M
$ H/ M7 k' F8 v8 O5 S- c
|