准备文件:
) o, z* p% W; ~ H/ c% gwget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
( [1 y5 {7 }; R+ Btar xvzf openssl-1.1.0f.tar.gz
! Q& Y" K( j1 cwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz+ P$ Z; H, q u" B
tar xvzf pcre-8.41.tar.gz
5 C; X3 c9 A# X" D
- i" Z# B1 P( X3 s! i; cwget http://nginx.org/download/nginx-1.13.6.tar.gz
- P& X' j4 {: J* r' _) Etart xvzf nginx-1.13.6.tar.gz2 R! V* w. G" s8 P8 V# y& g) W
5 U0 [3 ]+ s" w% l$ T& N, m
wget https://github.com/openresty/sregex/archive/master.zip
, `# | r& i9 dmv master.zip replace-filter-nginx-module-master.zip5 i+ N1 F1 p! H4 y
unzip replace-filter-nginx-module-master.zip, j3 m4 q6 k, `
: y+ Q$ |* R7 [# Y' a1 A# ^7 ^安装sregex
+ W! O! b8 i2 i$ f- ?+ a+ P[replace-filter-nginx-module-master关键词替换模块需要这个东西,如果不喜欢可以用ngx_http_substitutions_filter_module这个关键字替换模块]
& O) ?# I7 Y; t1 |2 a, s* ?( h! Iwget https://github.com/openresty/sregex/archive/master.zip" S4 B0 J0 C+ n: w- z' K& ]& Z
mv master.zip sregex.zip
. r) f# O! v+ v9 u; v; {4 o7 tunzip sregex.zip6 ^) `6 M( ?. a. A& d" g, `
cd sregex+ S& m' ]/ a1 q/ O# F* t
make && make installln -s /usr/lib/libsregex.so.0 /usr/local/lib/libsregex.so.0.0.1 #按实际情况调整' E7 Y0 a/ v- V. D
ldconfig3 a, _4 I& v6 I( b
. [$ @$ f& z! _: D安装modsecurity/ _( |$ n `# J
『依赖的包:pcre httpd-devel libxml2 apr 视情况安装。yum install httpd-devel apr apr-util-devel apr-devel pcre pcre-devel libxml2 libxml2-devel)』3 W6 p$ T8 C# C$ ?* W% Q
git clone https://github.com/SpiderLabs/ModSecurity.git mod_security& Z, v# H' N/ Z3 c& S% \( I
cd mod_security
( t7 i6 _0 N3 J5 d# z2 U./autogen.sh 8 q+ q$ g7 J& U: W: D
./configure --enable-standalone-module4 Z; d2 Z7 `! q
make3 B8 T4 Y J: m; f% k
3 F9 S1 i& S' E5 R$ o
, a& _& d- v+ b2 s安装nginx
; |( \4 M; y8 h. G( i+ rcd nginx-1.13.6. w4 U. O% q0 H+ f2 n, M
/ z7 W: W6 Z1 c* k
[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 - @+ A, w0 f- [3 F
make
. [) o5 Y% M: }8 h+ [, w1 Cmake install
6 O5 r5 Z0 V4 m6 ~# J/ H
. `' S& \1 w' ^) I$ @6 t% {- D注:--with-ipv6 已经被移除默认支持ipv6, --with-http_spdy 已经被移除合并到--with-http_v2_module
Q, D! P2 r, \8 W) T( M& S4 C* @ E- W3 }, ^0 b: ~, x# _
4 ~/ G( _4 ~: ]5 l
- \# @/ u0 Z1 s& q5 N
1 R Q. K0 K8 [6 o/ D$ ?' _% M" N& T' H
% ?. P X: B8 N5 Q, N4 }! m* F& X. d5 u
; `$ C0 e+ Q. h7 T
: `) A* y0 V. E, _& N5 ^ |