准备文件:% V1 U T' _# Z- G- w, ~' L! C4 A
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz; z: C3 T7 l* }
tar xvzf openssl-1.1.0f.tar.gz3 u) _3 P( l; `! }! {& {/ g
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz$ K, }& C" z) R$ v/ B1 \
tar xvzf pcre-8.41.tar.gz& E- p: w/ I/ T
- B/ J; d8 u Owget http://nginx.org/download/nginx-1.13.6.tar.gz
( `4 J. p! r3 Atart xvzf nginx-1.13.6.tar.gz
& j# {9 Q: @( U0 n3 ^) i
$ y) A* {1 ^# v) }- h8 U0 @/ ~wget https://github.com/openresty/sregex/archive/master.zip$ _( @. D @( l' e4 {8 o: s
mv master.zip replace-filter-nginx-module-master.zip0 C9 ]+ E+ q8 Y% X
unzip replace-filter-nginx-module-master.zip
1 t w4 u5 ]4 P1 [0 d8 S6 [
! u9 ]0 n+ j; W" A安装sregex9 ?- X! K' y9 Z3 i% j
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]; `" k' _, m: K$ R' B" L; T
wget https://github.com/openresty/sregex/archive/master.zip s, ]& J t" `4 D# [
mv master.zip sregex.zip
: K$ J5 a! I# f1 `& F0 Ounzip sregex.zip; |% M' {1 r7 C0 M
cd sregex2 g- i# [# ?# o+ ^. e
make && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
. W) e: ~* f. }6 ildconfig
* S% y+ a7 f c
7 Z5 j7 w9 o) y/ ^" d& m) v安装modsecurity
1 U* A+ W. c/ U4 N9 `- F『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』
4 T/ m/ n" z E& C [7 d0 C0 \" ogit clone https://github.com/SpiderLabs/ModSecurity.git mod_security/ r$ ?2 o! `' v
cd mod_security1 Y% m1 {- m# B7 @2 [
./autogen.sh
; T' l i" m9 [" d1 y N./configure --enable-standalone-module
3 n# Z! z+ S9 a" v3 _( G4 kmake9 j9 [- A! f/ ]9 b
4 W7 L, L0 J* `7 U
4 E' t! k& ? M# m安装nginx3 o# {8 o: H# a1 O5 ~
cd nginx-1.13.6
& c+ y: V+ V3 D. b
0 U/ l" c, I( i: y% Q0 ?[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 ) J; x$ C1 N$ V
make
! t8 f: n& v- ^2 \1 _' [. Nmake install- ?/ c0 |5 V+ Z$ D
* a4 k a/ C0 r$ U注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
0 [6 ^* N# q! V8 F; i% ?! K( c
2 \; ]0 @9 k C# v
) s* M) K7 T1 m B. t2 ?5 J
+ t# P' p' y) A% U8 y% J+ n8 S/ f* j% W3 n. o# r" w4 ^8 f0 `1 H9 C* ^
6 X9 ^3 J7 F0 `
6 M$ C+ Z( f9 u8 U! |) ^+ F0 R( }
* k+ j3 U% G4 Y2 C
0 c" g, K4 h1 D: s$ S% h |