准备文件:
# z+ H7 ^5 i# u5 X/ L: Dwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
% c1 c4 J Z, ?( ptar xvzf openssl-1.1.0f.tar.gz0 B- N' e- d5 ^5 }" t5 s, M
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz2 Q( \1 m4 c, _0 p$ ^. H' w$ t# x: ~
tar xvzf pcre-8.41.tar.gz$ _1 D% b1 L' f6 N- E
5 B {' |' ?" d, |% W; y, U1 Zwget http://nginx.org/download/nginx-1.13.6.tar.gz6 s7 i4 I5 h; L( n# W& e9 M
tart xvzf nginx-1.13.6.tar.gz7 K4 g9 x7 B) ?$ q+ j% o5 `
7 h* b, w' P' R1 U9 M# U) r( \& ]6 Wwget https://github.com/openresty/sregex/archive/master.zip/ T+ W, Q, @$ z! ?6 g
mv master.zip replace-filter-nginx-module-master.zip
% o0 i; D5 w& D- z: b; Ounzip replace-filter-nginx-module-master.zip
- @. t2 e5 C* q0 P3 l8 t: x( A. e- {$ q% i5 b9 o' N9 z
安装sregex7 O: S' ~6 ~0 V7 T( c+ x5 r
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]' Q+ H9 D3 z% Q' R e4 ~
wget https://github.com/openresty/sregex/archive/master.zip8 T8 K, j& z3 k3 Z
mv master.zip sregex.zip: R7 E* W) h* ^: l: N
unzip sregex.zip
. c: f4 w% ?8 @& Q6 e6 ]4 O5 n1 w: ]cd sregex3 H% E' U1 k, g
make && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整( W# z& _+ i! s0 k0 S$ V
ldconfig
- R2 d9 h- A+ ]" E1 {3 C; x8 w8 P
: ~3 ^9 H9 e# Z' A ~1 R安装modsecurity
6 O3 |: Z# m# @2 f+ U6 t& _『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』7 P! W% G# |2 y- ?" j: i0 t
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security" Y* _3 [5 ^- b, G/ q* Q
cd mod_security( ^0 E' |) R& m% z/ A
./autogen.sh 1 }6 ~4 z/ W% q; k
./configure --enable-standalone-module* B7 G( w' Q' U+ p
make! r. U: Z0 M) o. i% m
! W$ g, z; f7 M/ y
6 h! d) ~/ F8 D8 F$ I4 ]$ X( j
安装nginx
6 W% t+ p! [+ E8 c5 Icd nginx-1.13.6% q# a( ] M& w/ ]
0 w& I6 \' N! X[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
; m& w, z" h4 |2 _5 b; @, lmake
* G. T+ k9 I7 V8 O5 F6 G7 `" W6 amake install( @9 e- F& v- T3 T+ S
: { G. r" O7 j& h! E# J注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module$ g/ G" `, ^6 \& v2 c) T
' [$ C: ?$ L8 E7 B* k1 y* ~
- E& {! ~/ O6 q& O
h7 A8 i, J" M2 i5 v! K2 M# }
: Z- A$ E8 |- j% R( K' W1 ~( y# D9 Z
# X6 C# t' r1 ]
. c6 W4 \4 r( N; F1 z1 j9 t) Z3 ?0 R, n+ I9 |4 H
* @" r, ~3 ~( y4 x
|