准备文件:4 B% d/ D0 j" @& ^3 s. E; w: H& a
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz; j; d& B3 ?; V5 t
tar xvzf openssl-1.1.0f.tar.gz* B- h% f" O0 T z/ H+ {" D; |/ H9 O
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz, ]* L: a1 S/ x7 L
tar xvzf pcre-8.41.tar.gz/ F$ C. {, Q: o u
% g+ a) @0 q0 ~9 r/ T' G8 Owget http://nginx.org/download/nginx-1.13.6.tar.gz
2 K$ @0 ]5 |1 H# m, Btart xvzf nginx-1.13.6.tar.gz b$ q8 G$ H1 c. e' R5 t* T
) x2 X8 g# f+ O( s6 f$ `wget https://github.com/openresty/sregex/archive/master.zip4 i2 J/ K: }) P3 `- @, N
mv master.zip replace-filter-nginx-module-master.zip
: Q. S" O5 u$ {9 d- }. u% Ounzip replace-filter-nginx-module-master.zip
8 r- c4 D0 {4 N" X: R. }8 @+ E9 K8 Q, @% k
安装sregex
3 X+ s$ ^. K. T7 P: n[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]! q" g& k; z# l* Y+ m* w8 K9 J
wget https://github.com/openresty/sregex/archive/master.zip) L( Y7 @ `8 L& @
mv master.zip sregex.zip
- g6 `1 C! K3 d! sunzip sregex.zip9 Z0 T5 h4 c6 o' s7 Q
cd sregex1 }3 \) `! L r- M( l, @+ n
make && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整/ f2 m6 g* `8 l
ldconfig G1 h% y; b# [0 u1 e
: l7 Y6 ]$ f3 N# e8 ^
安装modsecurity
S! j; T* n+ k( f『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』
' D) _$ `4 o3 X9 y. Q, Qgit clone https://github.com/SpiderLabs/ModSecurity.git mod_security2 A/ W3 o7 t- o5 t* I9 s5 S5 i
cd mod_security' ^/ n' N: I3 ?; s( n) V+ J
./autogen.sh 6 Y, R& e+ y) h$ @7 E& R( `; d( Z4 g3 u
./configure --enable-standalone-module
5 o; ]4 r- a- v3 a9 amake& |/ U5 p: g" P/ e) A
5 ?) }2 i' a2 g* K8 H ?9 P
3 a/ f/ {" V* R2 Q4 Z安装nginx
6 E4 \. d1 ~6 _: B! m5 Ecd nginx-1.13.6
6 q3 _1 t8 X* V( T' w3 d/ L# Z
' I9 t+ e+ n5 d[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 / ] [' x% r+ G8 ~$ @* _1 g) L
make" |- u y7 x# L
make install& \& J1 ~, e9 Z: X
1 n5 {8 e9 O$ z* t C5 V6 W3 F注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
7 z' N& I% M# G, D# L& q9 }( C/ \7 b0 A* A, W; J# X% T; N
1 n) o/ S, g! c }- @! U( H
. \) P4 j# d1 X1 i. s2 ?9 N4 G
B: X& S9 v- l
5 L( f2 ?! K9 p; x, _2 a- |5 {* d" C P4 j. N
; Z& y. ]1 m' Q+ m
5 F7 v H" I0 U( M9 d
8 ?1 E- M. C% H* s# t |