准备文件:
" s* q( i5 `7 Uwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
$ P! Y9 c8 O* }0 O: x; r: m/ n$ itar xvzf openssl-1.1.0f.tar.gz
4 l6 L" I) b% l. U: m, owget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
/ N% l" N7 I! V9 j+ htar xvzf pcre-8.41.tar.gz7 Y! o! X+ s! o' Y) W6 O
( @. C0 S+ x2 l+ f9 D$ X% @6 ]7 A) }
wget http://nginx.org/download/nginx-1.13.6.tar.gz% @2 n) r; s) J
tart xvzf nginx-1.13.6.tar.gz
1 F' h+ l/ i+ D, [/ V) V& X" J- S A: x- }0 M ?% l; b
wget https://github.com/openresty/sregex/archive/master.zip
* Y: m# Z6 J3 L. z l Z/ l( B3 ymv master.zip replace-filter-nginx-module-master.zip
8 M* ]& ?( Z; l+ v% \( bunzip replace-filter-nginx-module-master.zip
2 K0 T; Z! Z' g c) h, j, Y# U' e3 u: B a0 z$ d% \0 Q: g
安装sregex
( p& K2 r% g6 p1 K- a4 V, q[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]6 k; s+ m9 q( U/ {5 E f
wget https://github.com/openresty/sregex/archive/master.zip
" F3 W. X2 c% |: C' {$ W* fmv master.zip sregex.zip
5 W) ]1 M9 o o& M4 l" gunzip sregex.zip
- O+ p1 g6 i; C0 Z, \" ~+ |cd sregex* ?6 {0 Z F! c* H
make && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
4 H" V o; l2 C" Sldconfig
6 _7 S8 K j+ M( X2 K
" }6 k5 @0 t2 T) ^, m9 F; |安装modsecurity
4 j- X8 n2 Z, p1 S' x. r: W『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』! m3 f( N) C. D$ T
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security. S/ Y4 |; s" S7 d3 T7 N
cd mod_security6 @+ q/ n% P4 \5 b
./autogen.sh ' d% P% H: B5 D: v, k
./configure --enable-standalone-module" Q7 E' c, q1 h. z9 {" G% o3 \
make
+ y2 s! k1 k$ A$ L% D# i5 I* s; E& m/ P) x9 p3 c2 y) j2 @
B$ [. R+ }! Y. U. r, V3 s3 a
安装nginx
0 Y& L) f# Q D Ccd nginx-1.13.6" X! ]6 b0 V& r1 M) W# A, y
, s: `, n7 T' A( L3 _( Y8 }
[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 & T% U2 ]4 F8 g
make8 W0 m) x N; _3 |, M. \' j) ?
make install
/ v, E- L$ J9 x2 ]: T" x
; W# o' H7 ]5 S+ U/ _$ Z注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module- j5 I( ~# v; i' U
9 T1 Q: D2 `; c5 _" i. J) [6 f5 ?/ f4 w* x o L! L. u! ?
# O; M+ }7 ?- }% B: L- q; s% _
, z5 k; K! b3 g4 `* a0 P8 {
6 m. o; y) M& m, Y* r' b! }# [, x* e' N( \
0 _/ t8 k+ k4 y2 G8 C, H
' K+ @" z1 F4 m. ^2 l9 F
0 j, V& M# ]# h/ S
|