准备文件:8 p2 ~8 R! ~# |8 h3 ~! Z. C' a
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
+ c& P1 G1 G" Ztar xvzf openssl-1.1.0f.tar.gz
! K4 B) s, T5 _wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz# W% s9 z* L: A. ^& l' u
tar xvzf pcre-8.41.tar.gz
! U# F4 l7 k: v9 e) Q7 ?3 M- `# O. ~! x/ `0 M, }% h: V$ \4 C; }" e
wget http://nginx.org/download/nginx-1.13.6.tar.gz- P# p0 V& G" @
tart xvzf nginx-1.13.6.tar.gz" o! s/ _" D( T8 k
( E6 p4 O4 _) |8 z1 t. m
wget https://github.com/openresty/sregex/archive/master.zip4 M- B( i- Z8 V: m
mv master.zip replace-filter-nginx-module-master.zip
$ l* P' ?9 O! Sunzip replace-filter-nginx-module-master.zip
4 y) m$ V6 N% v# T" M0 @
5 T; Y5 a" M, J# Y# i: V1 p) j安装sregex2 H5 u7 H/ z# B8 r, d
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]
9 h( D; b* p% ?wget https://github.com/openresty/sregex/archive/master.zip2 Q$ M: s/ Z* z3 z# Q
mv master.zip sregex.zip
1 p3 ?1 I' z5 [unzip sregex.zip
. C; v8 n$ ^0 ccd sregex
# o! g' B8 U$ j" e; G$ v- Fmake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
/ T7 Y* S- N ]4 H2 Zldconfig* C- x/ b" Z0 W+ J& R$ _
! l. v( T8 W5 n安装modsecurity- c4 W9 U4 Z9 B% `+ Q, H
『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』/ W) ^. z! \) L, Y$ u! t. r
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security3 e Y- B1 h: }* } }' w
cd mod_security- B* ` l2 ?9 V8 ~
./autogen.sh
; M) F$ q0 ^" r$ ?./configure --enable-standalone-module) v4 Y, W6 N/ |% ` m; c" P' }
make. K5 u3 e, f {+ ?# t" ~1 r
! t; S9 u! A5 m, h2 g9 |
, m* y+ v2 G- J/ V- U
安装nginx4 t) j/ I$ N- D% T% R" j& G
cd nginx-1.13.64 j4 v: F# I8 a T* ]* _
$ o U& R8 X0 x/ H/ K4 a[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 $ j9 D0 _2 {8 |
make
8 t9 n9 M& { |: w8 l( Umake install
: S9 y7 C# D0 L/ E3 }2 Q' V0 a8 l+ @8 Y" \; l8 B
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module5 s" I8 v" E$ h0 _* q0 \+ |
2 @/ G: Z7 f( X1 G" s% U6 q3 L3 F4 }3 U& R9 ~5 ^- x# c1 z; F% B
+ s2 Q: F) e4 k. w
0 K; C; K3 w/ \
! E ` E) J' a: x% X; k# _8 U+ D4 k
5 ~3 s4 i2 Z5 p0 c9 a, z( g; J+ X7 e
, L- u; @: N. M/ I+ K
+ v; L3 j) V/ B) {0 Q. l
% n0 R0 u+ k) }; a8 m7 {0 X- @0 E7 C |