准备文件:
6 m+ q& L+ ^+ E8 {/ `, Twget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
5 S7 d9 t3 Y G6 Utar xvzf openssl-1.1.0f.tar.gz. J5 x6 } n! C! Q
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz* i2 `/ N' O: W' X' Z4 F: J3 f0 u
tar xvzf pcre-8.41.tar.gz' j9 ~9 \7 F* W) `( |, C
0 x, i' @* t2 o5 {3 D
wget http://nginx.org/download/nginx-1.13.6.tar.gz/ T% U1 Q$ U* o9 q% B" v9 o
tart xvzf nginx-1.13.6.tar.gz
5 b. s' c( l6 s0 K5 V: J' I
9 [6 d& o. c @& {1 u uwget https://github.com/openresty/sregex/archive/master.zip
( x' ?% x' ^2 I, ~& E) Nmv master.zip replace-filter-nginx-module-master.zip
2 q; y- ?1 _+ R: f9 R8 nunzip replace-filter-nginx-module-master.zip$ L5 p; B- {" t6 [ m8 d% H
7 R2 |! A0 K6 V& Q/ L. z2 I" e
安装sregex
) k0 _, ?! s3 u- p Y3 s! i6 f[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]
, q( a+ V A1 k% G8 I9 iwget https://github.com/openresty/sregex/archive/master.zip" T5 v1 A( m5 \1 U2 g0 }2 i* [2 Z7 C
mv master.zip sregex.zip
3 @0 x; B" F, G) funzip sregex.zip
* H/ p0 c6 M+ m, zcd sregex
9 B( i8 ]/ d3 ?3 w8 ]" ymake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
0 ~. @9 @- S! yldconfig
! N% Z; a# S( i2 S& Y2 P; U/ O: ]- w% \4 e
安装modsecurity
# M( i0 U- k+ [! t6 ^, F6 C9 M3 ]; r『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』
+ w- X6 P+ h9 T7 s% ~/ ygit clone https://github.com/SpiderLabs/ModSecurity.git mod_security" {- W: L+ a/ Q* \
cd mod_security
9 L- w ^$ y/ `7 w. |5 T9 N./autogen.sh . ^8 n: Q. f. f3 | H% z/ m
./configure --enable-standalone-module$ w3 u) {; J) Z' k7 \/ M9 Q
make5 h' R) v. {: c" k% r! U; U
5 I+ C0 ?0 B2 c1 j
* v/ M! z1 a$ k8 L4 \/ k5 G安装nginx$ M4 n* F3 N1 c$ x" U. o
cd nginx-1.13.6
$ S. S0 B: T( d$ [
4 }0 t& k7 E9 B[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 0 @4 C( `3 _- q5 I/ S% t) T
make
0 h1 E- t% ~1 }* M( A5 Gmake install
2 }# |! S6 h" s6 q
. Q0 P0 r, ?5 q0 @$ W0 A注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
l' n7 q7 Z u, p' N+ H
i. D* ]4 P# `5 l3 _' Z, G9 }
1 e* V- a4 z3 |; l, g( I8 a0 K! L* o
4 s9 _: G& L% U4 y
' m/ T$ g0 S; Q9 @ ^& ^9 r$ ]3 \# ^- }+ q3 n Y1 C) W
! O$ V2 D5 ~. R( p. Y3 y# l
1 }6 d7 f3 J5 y) e% n9 g
! _9 L# v2 ]; l |