准备文件:
1 `; c& i( x# _" |3 g% a2 dwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
8 E$ S( @$ l- A+ i2 {- {tar xvzf openssl-1.1.0f.tar.gz
, A$ ^4 z' r' m! U& U1 swget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
g% F$ i- O: ltar xvzf pcre-8.41.tar.gz) k. X1 i6 K5 f) y7 F& h1 t
_3 I: Z8 `: W' F _4 r7 H& F' Nwget http://nginx.org/download/nginx-1.13.6.tar.gz
. d; J7 b0 y0 P) ^9 |- I0 Dtart xvzf nginx-1.13.6.tar.gz! c; o' T0 b7 Z8 U: K
& H, M3 K0 ^/ M9 z; ?2 D6 ]wget https://github.com/openresty/sregex/archive/master.zip
( a/ _2 E. e$ k) I$ [; Vmv master.zip replace-filter-nginx-module-master.zip
: e& B# Z$ e3 y" Xunzip replace-filter-nginx-module-master.zip
j- [' P S' r. N* T/ {
9 ]% G+ B; M6 u2 O安装sregex
. s1 o* u z+ x0 _[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]5 P( L: a) F/ w) k5 i3 T
wget https://github.com/openresty/sregex/archive/master.zip
+ y# w3 V4 @ y) T' h- g* d6 Dmv master.zip sregex.zip
- V; @% y9 m; `3 e8 P: H7 ?# ~unzip sregex.zip
+ y, n7 A, E; C0 fcd sregex9 D+ M0 \: ~# L
make && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
- d Y0 ^7 Z- d% J* z) _* [% eldconfig
# C. U8 o6 @% S/ k8 I% C) l( }# B: Y
安装modsecurity
3 O7 q/ _$ j" k, E5 g+ i. p# a8 R『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』" J* O. d( g. V3 e; e( M: Y
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security
# @7 L4 F: S% N: ?. u; R, zcd mod_security
0 X2 q$ R* H6 y1 ]5 X. U./autogen.sh
: V3 t4 `8 Y& [8 n./configure --enable-standalone-module
. S( o' ? V6 g L2 l# C9 Omake+ x+ d. @6 w# R1 u5 B, g5 u
6 D6 m9 h$ d$ j3 {
& g8 j p( B6 F9 i+ d: r安装nginx1 ~1 R+ `& ~2 d& y6 J. L& ?2 k( K
cd nginx-1.13.6( S1 s# D8 w9 [) @; s
: J a6 @- s, c[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
) w3 W7 `% l0 d5 ^, Smake8 n5 _& S) n6 L5 i4 T2 Z
make install
6 o! [/ Y6 {3 G' G' H. R0 \8 @* d3 H3 H+ F
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module }* K$ F* `# A. {1 D
5 z5 ~' C/ ]0 Y% h5 ?
3 t% h3 o- w/ M" p- s% w9 t( i n: }7 {5 `+ |: V) w A; Z
; B' U( ?" z9 I$ W
) [9 ]0 e& ^5 O1 O& A# }5 z+ d5 [; q* W, P
v$ [0 B- t8 Y( Y, B
4 ^- `" f3 t* ?1 G9 ^4 [3 s W' ~
0 z7 ~4 Z/ `- l! X t% e
|