准备文件:- o3 C2 L2 k" A/ V7 i
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
/ R5 F6 j6 P+ F7 M* h6 btar xvzf openssl-1.1.0f.tar.gz0 V! J9 ]2 s' G7 j
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
; H1 u' Q9 F3 D1 Btar xvzf pcre-8.41.tar.gz/ X/ } M( j, O! Q& m3 O* @4 i
! _) ^: \, s( v# T$ F( l2 }/ X
wget http://nginx.org/download/nginx-1.13.6.tar.gz
$ U9 f* i+ f. s7 p, ftart xvzf nginx-1.13.6.tar.gz/ f ?" T1 l, Y' T' k+ d# a
: q0 X$ Y* v0 N% q: @7 ]6 A# _) g
wget https://github.com/openresty/sregex/archive/master.zip
; F# B( J8 t& q: {2 a8 f" T- }9 omv master.zip replace-filter-nginx-module-master.zip
* q$ ~ v8 w5 a. @5 r. J$ runzip replace-filter-nginx-module-master.zip
3 n! b$ z0 z9 X2 T, M+ S/ H8 @9 i$ u
安装sregex
) N7 {! G2 B. H/ F( M! `* ^3 K2 w[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]2 B0 k) @% H/ w6 L) Y
wget https://github.com/openresty/sregex/archive/master.zip
4 c# f6 S$ E0 _mv master.zip sregex.zip0 ^$ U& I! ~! A9 Y7 x5 `
unzip sregex.zip
, t5 p, v8 r; U" mcd sregex
& X6 O3 W- x" \4 P2 F) ?3 C; tmake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整# g2 e0 F0 d( t
ldconfig" L3 R, K! M- L: v
0 U0 f: {! Z1 p, d: r& L$ E$ V安装modsecurity! E$ p* D9 Z! C7 P
『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』& A9 W7 q1 M( y% A/ E
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security
+ t5 m' V# Q/ Acd mod_security
5 z4 \( d8 d. f4 C: E7 g./autogen.sh
1 F, a2 H; J/ F- ]./configure --enable-standalone-module
6 g+ n- q/ x j: j" D! jmake
! u5 T8 ]* z8 Z
* l9 b* w- |' O" k V- c5 y% x
. t0 J4 J3 F8 j8 U; P5 b! Z0 b安装nginx
) H Z+ y! C! s7 t& @8 S% O, {/ h/ Mcd nginx-1.13.6
, m2 t2 I: D1 _, y5 |
6 [% N8 l% A1 B% h[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
2 Y* b8 m) Z' K2 [8 Smake% H" O7 a+ x# l9 d3 \
make install! N4 a( m5 r% b# ^
( j* M# r( h s8 y) W1 z9 E& N. \2 w
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
- N# `8 \5 P* g$ @! `" z1 V: m# a7 }' y+ [2 C$ `( H# k) y! P
# y/ G8 \. N4 M. L7 C( C
9 P, D- T/ @4 @" e$ c5 z6 u8 x3 n( a# G( P! [9 N8 V$ j
" Y0 Q( b9 _7 a8 `3 s
5 i, ~3 g1 B/ h5 r. `3 S
3 ]9 D! q0 Z% g
1 E/ a w% f- ] i1 v& o! M% B1 M: b7 c2 h
|