准备文件:
6 `) K( v7 B) u- b- rwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz4 u# I0 ]' j! W j0 h7 P7 \! P# h2 U3 _3 l
tar xvzf openssl-1.1.0f.tar.gz
5 n$ O# D2 _- _: i7 P4 Y% E) m8 ]( r' vwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz, y+ H3 p; P. l9 @* Y# U8 g
tar xvzf pcre-8.41.tar.gz. Q' f# X& v! v `7 s/ R4 I% M
1 N/ J) O# X, [& Lwget http://nginx.org/download/nginx-1.13.6.tar.gz
. p, N* ?* H! w/ d" x% M- Y1 S( atart xvzf nginx-1.13.6.tar.gz
" Q/ x4 W' A! p( a- d6 q; k
: J! U% S6 E I, o( {" Z! [1 Cwget https://github.com/openresty/sregex/archive/master.zip" {- a+ {# o8 I- Y* x* a3 z
mv master.zip replace-filter-nginx-module-master.zip* f6 X" d- g: {2 H, J/ w; F V
unzip replace-filter-nginx-module-master.zip1 z$ c0 V" j+ q0 s( W8 v
- b* i9 `3 c1 F
安装sregex" p4 J9 {* {. @% q/ }7 p1 I+ ~# m/ D
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]
' Q6 K, |9 L* uwget https://github.com/openresty/sregex/archive/master.zip
$ L" z" n4 v0 c$ S: k' ^5 pmv master.zip sregex.zip/ S* X7 Q3 X X) Z* X/ y: Z, H
unzip sregex.zip0 n, ]' h, U2 @4 d4 h
cd sregex
' {: k0 T8 s# u- Emake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整; x |& c5 P/ v* C/ r) }
ldconfig
/ t+ w. f9 o( w& j5 |- h7 s4 W, X% _1 {. z% Q$ d; d% t I
安装modsecurity; }; l: r9 f( s# D( m# X0 o
『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』1 c& @7 Z A, _0 l9 Y5 q
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security
: D! l, a; r: V4 e5 S5 c$ [cd mod_security
+ x( w( ?9 X3 i' y3 R: G./autogen.sh
: Y) x5 j* j: p, ~./configure --enable-standalone-module
$ p+ X* D1 h; Hmake- @* K$ m1 C4 d+ I& p0 m8 t7 [ f
7 K# ]$ q0 y: ~. y5 s
$ L3 K! j5 v) a0 T6 ~安装nginx
- Z5 y" y* i. X3 D# e$ t! d2 e3 ?: [2 scd nginx-1.13.62 D5 f+ }. S Y! [& o
: J2 C& u# }) s" |; H. w[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 1 a3 T1 [2 o' w
make! g& S3 R) s. e- m
make install
2 R$ Z. y. ]; [ E( s$ t$ k
9 [7 Q' A8 y% X6 a* {9 Y( b注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module; K$ ^; Y: N: M4 t/ T+ X
* w1 D: G& P" i9 s. R8 T. }4 b, s* L( A; b: I2 m I
. M1 r- u k" ]2 q( u5 N8 n+ ?; a( t
B6 S0 G/ k6 T4 z, k. Z2 G
5 J; s) K+ }. ]9 d& `7 y' N/ F. W" G
8 b6 Q1 [* F( z4 g% K, D
4 {) }4 s( {* \* w/ B$ h! f |