准备文件:
( I3 ^6 h6 k& ?8 cwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz. M$ C$ t4 x+ S4 v: F- v) e1 m
tar xvzf openssl-1.1.0f.tar.gz
8 G; ~0 D5 }. r2 `; g% Kwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz5 h5 r1 |- e$ ^5 p) n3 [1 B+ Y' R
tar xvzf pcre-8.41.tar.gz
* `1 n7 \- ? G% Z$ l& k6 b5 {5 d A& k- r5 j
wget http://nginx.org/download/nginx-1.13.6.tar.gz
6 L% ]) ^9 O, b1 ^; f& r5 etart xvzf nginx-1.13.6.tar.gz
3 i' f& H8 B8 H }# t; C( A# h$ y' d
4 @+ R5 O: v8 J% t& ewget https://github.com/openresty/sregex/archive/master.zip
$ ~( M% S( }" E* h1 emv master.zip replace-filter-nginx-module-master.zip1 t+ o7 _7 ]) W0 T$ @3 p. [
unzip replace-filter-nginx-module-master.zip3 t7 A4 O' @8 p% [+ ~7 s# l
+ B- l: N* x3 W1 a- Z. H! A安装sregex
" H! n! d$ q) m* o+ a& x/ i1 o[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]
4 ]' v* }6 V( I# b& P; J$ Wwget https://github.com/openresty/sregex/archive/master.zip
d& M, i+ F) B a. F( w8 }2 Imv master.zip sregex.zip' W" b& K9 a/ x; n; E0 s
unzip sregex.zip
h% N/ F1 v! w) A, U4 s" }0 J9 Wcd sregex
" H+ F7 _+ B6 ]& rmake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
; ?* q. u+ T. j8 z3 G# Nldconfig4 I( @+ D" V( j; q& e/ _
0 E" p( g4 O6 f7 S
安装modsecurity
( `5 T V, E% t g7 T『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』
/ Q5 c7 V" ?- W6 g( Sgit clone https://github.com/SpiderLabs/ModSecurity.git mod_security. H, U4 s1 V" I& y4 f/ Q8 v; |8 ^
cd mod_security9 {( I; m$ |: o0 c. x6 S$ n
./autogen.sh / n' R# Q0 ]1 o, n7 n
./configure --enable-standalone-module+ D* a, e: H4 h7 E$ I
make
3 `" n. f1 N* ^/ l$ _0 O' r
, J$ N/ ]7 \+ s1 k+ y' v K) [4 ], O& m( V( ]$ G
安装nginx
1 I3 `7 _7 W0 ~6 k8 N pcd nginx-1.13.6
2 q+ S9 ~" Q8 [. j4 ^$ [1 \! x- L+ J: p+ Z* z* q2 W$ 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 ) y, H3 x" C; I: n3 ]4 l; w3 R
make
% X# U: Z+ T& ?) b( Kmake install
4 w( f: r( F4 Z7 R8 p$ z" H0 z7 Q* W. ?" _# t: i& J. I
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module' O: T4 c1 T) @/ ~
3 I% c) _8 |; y9 S% c% w* Z, c$ R% s. T
5 L; ~$ I" n! D$ u( e+ K4 i+ t J) _1 [. u3 _* f* j
5 B1 `6 i1 q$ I. P6 z3 a
" z; U8 P# I' g6 n
% |; U& k: X9 x2 y- f9 i4 T
. S; w2 Z. ?3 l' f
8 ~4 k* H7 t0 Y8 g4 d# r& x% X |