准备文件:
* u. P8 t8 {, m' D+ q0 o& ^. G! Zwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz$ Q9 h' M6 ^# r) `
tar xvzf openssl-1.1.0f.tar.gz
5 D4 h) Q; T2 O0 i: b. B+ y9 b3 qwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz+ ?% A7 W6 v( a$ ~
tar xvzf pcre-8.41.tar.gz/ t! o6 {9 a$ Q1 K" r9 i9 [
; X% l/ U4 h% F. o! ]& j0 s: V
wget http://nginx.org/download/nginx-1.13.6.tar.gz
* a# o! }3 D3 @5 A+ \ p7 T. K. gtart xvzf nginx-1.13.6.tar.gz& R" M" c# s7 | i( n
: R2 i% y- y8 z7 Z" [) \7 K1 X. l
wget https://github.com/openresty/sregex/archive/master.zip
5 I( s2 I7 z' q% O/ {5 Amv master.zip replace-filter-nginx-module-master.zip& s" P0 n8 S3 N# k, v& T
unzip replace-filter-nginx-module-master.zip
) j' H, s* e4 S7 D. \2 M% Z. I$ X4 K, T3 |( {9 a0 g# M! P
安装sregex8 w& ^2 Y( O1 Y' }
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]
* A: ]/ S6 C) R" `; P9 N: Iwget https://github.com/openresty/sregex/archive/master.zip0 X# [, Z: p# |
mv master.zip sregex.zip+ g- c8 c7 g9 H" J2 d: I
unzip sregex.zip
- R/ p$ Y0 m* e7 u6 g" K' mcd sregex9 ~0 z( n" ?; N! v/ {8 s
make && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
: a; h a3 O% J( pldconfig" }$ R. B8 T( j6 Y
R6 L: C' S- Y; i
安装modsecurity
' H+ D; D4 N) t! w. n『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』
: d+ [) u+ A& n/ ]git clone https://github.com/SpiderLabs/ModSecurity.git mod_security
& l$ B) z/ b+ j, z% v/ Ucd mod_security' p8 c: V( ^- r4 {! z i* R; v
./autogen.sh
# ?" n: p, _; d7 N, {./configure --enable-standalone-module
# q- d9 X% E4 b$ R% ?make
6 |8 f5 g" f4 H0 R& v& F
: h' H: _6 Q$ M* ?. Q# @1 z5 m& }' o* H& [. ~& C
安装nginx
# f1 L9 e, p3 |7 @) b- z$ Jcd nginx-1.13.6
$ O# U- }. G& \, c/ ?8 b9 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
8 k4 j" m1 @6 P2 e& w4 e' r, Mmake- Q$ X( I$ [. B" L0 c9 f
make install. a9 Y# I; n4 @7 u, Y- x
* v8 L6 H, T4 g2 j
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
5 {- S( E9 r% F+ j% h
9 L8 _; M; R7 z8 \" i" o$ T" D4 E4 z3 J7 m T$ M6 A/ S9 N
! B5 w' t0 _* E1 {" m+ Z; L6 p7 g& ^; o: P3 J4 o% x% s
) ?( j( [# M# B
: w, c" z4 E4 w9 S# C
. p0 z* `3 T! z5 U) M3 Y% T4 X3 m: m' Z5 p. F
9 U9 i2 n% G+ H, w: G1 O4 P9 ]0 n2 b |