准备文件:" \& H9 v* G+ e; [
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz- J! G( T9 T' t9 C- n |$ p$ a
tar xvzf openssl-1.1.0f.tar.gz1 Z" E/ p+ X, J" W; E7 d
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
+ u Y3 T# o; V- g: \# htar xvzf pcre-8.41.tar.gz0 H3 H9 C5 f6 m
! w% j, N3 m0 \7 J
wget http://nginx.org/download/nginx-1.13.6.tar.gz9 D- G# Z' u' |- u
tart xvzf nginx-1.13.6.tar.gz
: E+ c2 {2 y# J; |0 W' M1 ^" y# v; Q
wget https://github.com/openresty/sregex/archive/master.zip7 ]2 u. |' E4 f5 v q! R; `& B! M
mv master.zip replace-filter-nginx-module-master.zip
h, Q- K* {) V& P. [6 r; {, gunzip replace-filter-nginx-module-master.zip
- [+ ^2 c- C& I% ` \2 h$ a/ U9 r
: N/ M- x7 t' g0 k7 p6 ]4 ]- P0 R安装sregex$ L$ H9 P2 q+ P* ~
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]
) P! P7 A; w, H. Hwget https://github.com/openresty/sregex/archive/master.zip
/ |! i- s' F R/ [) ~mv master.zip sregex.zip: k7 K! W: T' i
unzip sregex.zip' y# p! v2 u I: B; K( L
cd sregex
~) t% |8 O& x0 Vmake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整& r& Z/ c- b" N+ {
ldconfig# s' g q& x$ n T# N3 {) H1 A6 R
3 M5 V, u9 a5 b3 ]# d' L
安装modsecurity! B6 n- d& D! X/ {1 g l: \# D/ N2 [
『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』$ I# ]. J" Y6 n% S
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security
0 C+ P6 P# T0 p! ?8 ]) k' p# G) ~cd mod_security
" i- b4 [' d8 P2 C3 r./autogen.sh
: q! w, ]; Z5 m3 w! A$ M7 \3 ]# }./configure --enable-standalone-module c8 Z+ @! z! c) V5 w# }* f
make: R; N4 H) j1 S$ ^. G2 ?
% P! W9 V* U5 o* z1 l
/ D5 m- {, ]( f# V8 h( c6 K3 s
安装nginx
; {2 _5 E! z6 x" D; g7 Y( p9 pcd nginx-1.13.6
6 w `3 S3 C( G6 \
! B# X$ N( _/ t( g[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 @( X" Q- `( F
make
8 j l: j7 S( b: Z. |make install
. X1 ?) {# l# W( X0 D1 W8 a" R' N7 P- h' j% G' |4 l" D# {: |
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
0 o/ F G) r( R7 `5 k8 G$ L; Y+ B5 `; ?) z' V* I
9 ^) Q: `/ A; J, V/ e7 k. f: p! ]5 B. n9 a6 w
6 W- w1 V4 r! Y. J
c: u l/ a6 H3 _+ q3 K3 k! X7 V0 A! \8 C5 |9 r* `
( k0 N4 d. n7 p* L
" s0 \3 J* T' ~ V: ^
; F4 h' F' `0 [+ k6 o$ P2 @ |