#!/bin/bash   
useradd -s /sbin/nologin -M nginx    
yum install pcre pcre-devel zlib zlib-devel openssl-devel openssl patch gcc -y

mkdir /software;cd /software   
wget http://nginx.org/download/nginx-1.4.6.tar.gz    
wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz    
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.8.tar.gz    
wget https://codeload.github.com/yaoweibin/nginx_upstream_check_module/zip/master -O master.zip  
wget https://github.com/zls0424/ngx_req_status/archive/master.zip -O ngx_req_status.zip

tar zxvf GeoIP-1.4.8.tar.gz && cd GeoIP* && ./configure && make && make install
cd /software/ && tar zxvf nginx-1.4.6.tar.gz && tar zxvf ngx_cache_purge-2.1.tar.gz -C /usr/local/   
unzip -d /usr/local/ /software/master.zip    
unzip -d /usr/local/ /software/ngx_req_status.zip    
cd /software/nginx-1.4.6 && patch -p1 < /usr/local/nginx_upstream_check_module-master/check_1.2.6+.patch    
patch -p1 < /usr/local/ngx_req_status-master/write_filter.patch

cat > /etc/ld.so.conf << EOF   
include ld.so.conf.d/*.conf    
/usr/local/lib    
EOF

ldconfig
cd /software/nginx-1.4.6 && ./configure --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --user=nginx --group=nginx --with-pcre --with-http_gzip_static_module --with-http_ssl_module --with-http_realip_module --with-http_geoip_module --add-module=/usr/local/nginx_upstream_check_module-master --add-module=/usr/local/ngx_cache_purge-2.1 --add-module=/usr/local/ngx_req_status-master && make -j2 && make install


关于nginx_upstream_check的官方参考:https://github.com/yaoweibin/nginx_upstream_check_module/blob/master/README