准备文件:
; \, p0 R* |# Nwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
, a! j. ^& h Ztar xvzf openssl-1.1.0f.tar.gz8 }5 J: [6 d: v& c5 L
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz- j* Z' {0 x) ~! N' i8 B
tar xvzf pcre-8.41.tar.gz
8 I/ U% j1 m+ ^) D' Z3 d6 W* N1 J$ o, |. e* w1 s# l
wget http://nginx.org/download/nginx-1.13.6.tar.gz
4 n2 Y% X' k: @# u% u: U$ btart xvzf nginx-1.13.6.tar.gz2 q1 P: [: t8 n6 b+ |1 @- J
a% H8 C" s- W* q1 B
wget https://github.com/openresty/sregex/archive/master.zip
# F$ `( x$ k6 b+ Fmv master.zip replace-filter-nginx-module-master.zip
% j4 t* f$ j: xunzip replace-filter-nginx-module-master.zip+ K% d! M/ O( [+ @. l
+ P7 W/ W6 m) l0 ]$ ^* I1 V
安装sregex9 l" J) G( D; W, ?! \& H
[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]
2 a% h7 `( o- Q; ~3 \wget https://github.com/openresty/sregex/archive/master.zip
6 Z+ v& {" C6 _3 d0 z& Ymv master.zip sregex.zip
5 ~9 t+ j) o9 L* _9 sunzip sregex.zip
0 l3 N8 I$ }( F8 E+ y! D$ J) ^cd sregex
% _7 x0 v6 _/ ?, Emake && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整/ j' H+ I9 s2 ?9 b+ Q D9 i
ldconfig; ]1 t O' z5 j' o6 r. A
( N7 J8 P: `" ^7 j# v5 \
安装modsecurity
6 r" d/ ~+ v5 y1 O0 B『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』
: N+ H. \+ S9 b1 y! z, igit clone https://github.com/SpiderLabs/ModSecurity.git mod_security
) i6 p5 @5 X% T! v3 n( c3 Ccd mod_security
+ w, c# R) G/ ]./autogen.sh & Y( x4 l* s f) }$ @9 ^; a
./configure --enable-standalone-module1 J( Y, U! r1 n" I8 L3 L
make
$ G8 F$ i" C4 m, j. k' J, v
9 \/ `- N }1 P- _, N% y6 ?8 y4 D6 h+ P" C! L( x
安装nginx
5 B* o7 T2 k. y! [$ ^2 Vcd nginx-1.13.68 U* `) \) I j% l# |
u7 Z& e5 r, c$ Q; I) 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
: l. r5 C& {( Z( omake" [0 a& b9 p# v' r ?2 v7 Z
make install
. t; R$ l4 K* L3 h9 S
8 R! h- V) A. ]: @6 b! n: F注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
: a2 {( e4 c# j" _- o
7 P. I' I2 N. t" ?7 F( C5 t6 @8 t7 ?# P
( \5 E& i# _1 m+ L. `% b7 \" f {
# @7 q; S; g: L/ @
$ |" f( h" v* e% v2 z$ R o; `3 q" ^ w
2 h4 _2 Q& i2 A! W+ F; d6 Z
/ k* S' w3 r7 J
, Z% w5 n9 p* C( U, E# G
|