准备文件:
3 u, U2 }2 n3 p- J3 ^+ }8 R* ewget https://www.openssl.org/source/openssl-1.1.0f.tar.gz& K+ u% Y5 }0 W. s
tar xvzf openssl-1.1.0f.tar.gz" ~9 j. G0 D# p4 o3 M" g- O
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz4 |- C) P* p" ` Q
tar xvzf pcre-8.41.tar.gz7 q- H% [7 I9 i0 a4 w$ s
8 V6 ^4 I5 }# e/ Q1 T$ `# A7 n0 D, D
wget http://nginx.org/download/nginx-1.13.6.tar.gz
( ]& h# I4 L; v" rtart xvzf nginx-1.13.6.tar.gz( a3 a0 A3 V/ s/ ^$ n
% P" T) ~7 V p( G/ O" e4 T
wget https://github.com/openresty/sregex/archive/master.zip# g+ J. |. c1 y' O3 l
mv master.zip replace-filter-nginx-module-master.zip
' I7 L& b) ]0 ?5 u7 X: P- Yunzip replace-filter-nginx-module-master.zip; @1 _; A7 W( }! m0 Y+ I
. _, j; K7 M' h3 R安装sregex
6 G! I$ p5 d# U[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]7 b$ n9 s/ ^, a" I6 @9 I/ D( ]
wget https://github.com/openresty/sregex/archive/master.zip' D; @" k% g, S8 Z4 I, O
mv master.zip sregex.zip( i2 ?* w9 h6 z6 A
unzip sregex.zip
+ y2 s6 B! Z2 Q3 A+ P* F/ @cd sregex
3 K5 d6 V$ j. F- hmake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整: Q9 o @% x. p7 C8 @8 U- q- ^3 ]
ldconfig9 k4 _: f* A9 q) L6 X! ?5 }( \ ~
) R6 [/ M# {2 Y/ e2 Z6 S安装modsecurity, H% ]# ]& V: e; z6 k; u/ r
『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』3 t$ c z: A" H$ K: t. R
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security
, O$ D( r( V; E: jcd mod_security& @% e% ]: X1 b5 e$ I
./autogen.sh
. r, G$ F/ t1 @./configure --enable-standalone-module' T ]+ q% x7 A- ~$ g: @
make2 X0 r+ i0 }5 r! k3 g
# e1 _( C8 d1 s2 z$ [" {
$ P% V% s- m* _6 J, F
安装nginx8 S, P2 `* U6 `, ^6 n8 W
cd nginx-1.13.63 c7 S5 p* v: _* E5 W( ?/ q
* i- {# E; ]* 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
% P0 o, K. g3 `7 bmake
1 K4 {( A- r% q7 T9 bmake install2 j9 u; K4 q' }5 t9 L5 _. Z
& R# ]1 Y# m1 I1 r1 R8 S$ o) W6 w
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
# i+ @7 S4 s* d. X/ ]' ?! R1 r/ E' h' u
! v- l6 A4 y3 r4 a! A6 g! J% ~! W/ ^( L( b
U! i5 f- M) G% o4 b" T; T* |- Y' W& V( c: S) Z1 J% W. u3 Z
& {2 z& [; m! }5 m6 X, K$ o
$ B7 a/ X: o+ s8 ?6 x! I
+ K& s8 n9 W8 N3 [- l' K) ^1 a0 Z4 W0 ?; e8 `
|