准备文件:
8 d. h t8 P! J* fwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
+ {7 M. s# d& W# L( ztar xvzf openssl-1.1.0f.tar.gz
# g$ Q3 w' S A- I& R& Hwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
' ~5 ^+ q$ N: _9 E9 Jtar xvzf pcre-8.41.tar.gz4 O* n: [4 X5 q- s' x5 A9 D: t: _3 I* T
5 l: m; @. I9 m! j3 ?
wget http://nginx.org/download/nginx-1.13.6.tar.gz
1 u1 e& Q+ h6 N5 z/ w; a7 Start xvzf nginx-1.13.6.tar.gz
9 U1 [" V$ E# n: _; g' w3 m$ D7 I, X2 h, A% K6 k; p' L! i1 ?
wget https://github.com/openresty/sregex/archive/master.zip
! v* Y* u# w1 ?. Umv master.zip replace-filter-nginx-module-master.zip! T% s1 y" J5 c: i7 V
unzip replace-filter-nginx-module-master.zip; O8 d: c' K$ }" I3 G" u) @$ y" J
" Y$ o, i6 [/ `! Z5 |1 A安装sregex: `+ C7 w' G2 Y! N, J4 T7 |* Z
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]+ @1 t' e4 q- Y' j. D
wget https://github.com/openresty/sregex/archive/master.zip$ e/ [: ~, `2 U$ a4 Y- L
mv master.zip sregex.zip; @. C* t' U, E6 p8 [8 M4 b
unzip sregex.zip' g I* S& e5 Q4 B1 a! m: K2 b
cd sregex
8 P# V1 m P! Ymake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整
: I( J3 O1 Y8 [9 s6 [ldconfig
7 R, Q4 Y/ o! d) y5 X
; J' `7 x! O. j安装modsecurity
) b. l3 W* \* v2 O3 w4 `- w『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』6 u% @ [5 g! L! i6 L
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security
1 D9 P5 p+ z. @" M" [cd mod_security: Q0 U" Z- Y3 Z+ P' w% J5 q3 y5 n
./autogen.sh
: A/ \ l$ D# G' I1 }, e9 D8 t./configure --enable-standalone-module
. l7 i2 j2 K! w0 I5 z( ?7 imake+ b; X! `+ U4 s
' _, W; R7 W6 L, D
- o; d8 z* V: h9 v安装nginx/ L; ?0 |! M# T& F8 H; H9 {
cd nginx-1.13.6- _3 g/ _# o- }! d" a: L
( r* N% w$ t& H' J4 o[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
* U* f, H" c$ W. r6 dmake
7 C6 D6 R3 [, ]; @2 jmake install
$ F! o; m! G, h8 p# K( P5 ?! t8 P9 \- B' J$ z/ U( ^2 w
注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module8 l2 _1 n7 ~5 K1 ~2 @* P1 H
1 T Q$ @2 y1 n: [, d; B) p) a* X) f
~+ I3 X- A" v/ ^
5 p( I, ~0 n. |+ s
3 n- W F/ n5 q7 l
; O) @- `! d# R3 R a& @
4 S7 A: {- S7 t/ d" Q7 w4 \. @7 y' S8 G) E3 @4 L- o
: ^& f7 K" ?, m0 b. O5 o0 f
/ A' |& L( T. y/ @, y& j# R1 C/ {
|