准备文件:
# [- b m- h- k7 J' N: E; X" r0 Zwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz7 ~5 k! R- l9 l9 K( B& m1 A1 C
tar xvzf openssl-1.1.0f.tar.gz
% P$ s2 n& R9 E, gwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
$ h9 h0 W. s2 |4 Y% Gtar xvzf pcre-8.41.tar.gz% z2 d4 l9 k, o" L
& f# [; k; g7 m# e% L. M5 Bwget http://nginx.org/download/nginx-1.13.6.tar.gz
/ c; m7 i- _: j. etart xvzf nginx-1.13.6.tar.gz
2 A" i( U: F' D( r
( m& Y; {1 Q3 Z) Lwget https://github.com/openresty/sregex/archive/master.zip0 y% I( p& ~, R6 G7 {- G
mv master.zip replace-filter-nginx-module-master.zip# Y+ I8 S. x3 t4 p" M* g% f
unzip replace-filter-nginx-module-master.zip; f% A4 {; W/ C; K8 {
' n# Z2 R' h3 k$ k* n. m) |安装sregex
# U [. T, F2 t& ], r4 N[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]0 w. H2 m4 G5 }* x& B% l6 p
wget https://github.com/openresty/sregex/archive/master.zip4 `6 W: _7 y0 W h% k8 U( I
mv master.zip sregex.zip/ Y5 A" f- T' i9 q+ D5 A
unzip sregex.zip0 G4 D3 k% h. z4 B* G$ E
cd sregex
* O) J$ S! U2 zmake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
) \' Z# G& Y( }" c$ n5 uldconfig3 S# C, H1 P( L
8 L) q' Y. F/ o) `9 [% y# G
安装modsecurity
% U! [7 x4 s- [ x) o0 Z0 l1 J E『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』* Q& @) P+ c3 H7 d3 E
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security4 I4 m! f3 ~! l6 h3 U2 @/ Y
cd mod_security* I8 m* \- }% J4 x2 _* g
./autogen.sh 3 o! M/ H% U- i. i
./configure --enable-standalone-module9 S! I, u! H$ S8 k; m$ c
make( y0 t4 U" }. d( p9 |; t
( i! Z# X, [/ L1 C% Z- C! n) E5 u
/ O3 q/ D8 U1 I+ U4 O安装nginx
, |* X u; L& ]( P, Bcd nginx-1.13.64 G R9 T: h B+ a* c+ S
) {! u% }0 @2 T9 V7 r% [! ?
[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 7 ~0 B" Y7 n2 Z
make
, i3 `* H9 c/ E3 p* E# bmake install
5 T& k; N1 A# n% d) H, O
3 b: g( |2 {8 D* E注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module' S; V# c4 v$ l6 _/ t$ V" |- n2 H
6 ]5 [$ l. C! L1 S4 O
1 V3 c9 w7 R8 B4 l0 H. i9 Q" N
, Z) z/ w, P- U# P/ ~8 {, ?, L/ r3 u- m% K
$ F1 u `3 b% E5 ~$ L1 H) m& w/ n1 ] ?
N& B/ W) t8 E# I
2 u( i$ D7 `& V1 T1 q
0 s# o6 t! G- T& O3 j* S |