#!/bin/bash # ADD Module # 1: nginx-upstream-fair # Install_dir="/usr/local/nginx" Download_dir="/home/tools" Nginx_Major_Version="1.6" Nginx_Minor_Version="2" Nginx_Configure="./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_addition_module --with-http_auth_request_module --with-http_gunzip_module --add-module=../nginx-upstream-fair" check_result(){ if [ $1 != 0 ];then echo -e "\e[1,44m <==== Error,Exit install nginx ====> \e[0m" exit 1 fi } install_or_not(){ read -p "Install nginx, Input Y ; Do not install nginx,Input N:" INSTALL_OR_NOT case $INSTALL_OR_NOT in Y|y) install ;; N|n) echo -e "\e[0;44m <====Stop install Nginx====> \e[0m" exit 1 ;; *) echo -e "\e[1;44m Only Input Y or N \e[0m" install_or_not ;; esac } root_or_not(){ if [ `id -u` != 0 ] ; then echo -e "\e[1;44m <====You are not root,Please login in root!====> \e[0m" exit 1 fi } install_develop_tools(){ yum install gcc gcc-c++ pcre pcre-devel openssl openssl-devel wget unzip man -y check_result $? } download_nginx(){ [ ! -d ${Download_dir} ] && mkdir ${Download_dir} wget http://mirrors.sohu.com/nginx/nginx-${Nginx_Major_Version}.${Nginx_Minor_Version}.tar.gz -P ${Download_dir} check_result $? cd ${Download_dir} && tar xf nginx-${Nginx_Major_Version}.${Nginx_Minor_Version}.tar.gz check_result $? wget https://github.com/gnosek/nginx-upstream-fair/archive/master.zip -P ${Download_dir} check_result $? cd ${Download_dir} && mv master.zip nginx-upstream-fair.zip && unzip nginx-upstream-fair.zip && mv nginx-upstream-fair-master nginx-upstream-fair check_result $? } configure_install_nginx(){ if [ ! -d ${Download_dir}/nginx-${Nginx_Major_Version}.{Nginx_Minor_Version} ] && [ ! -d ${Download_dir}/nginx-upstream-fair ] ;then echo -e "\e[1;44m <=====Some sofeware is not exist=====> \e[0m" exit 1 else echo -e "\e[1;44m <=====Start confiugre nginx,make nginx, make install nginx=====> \e[0m" fi cd ${Download_dir}/nginx-${Nginx_Major_Version}.${Nginx_Minor_Version} ${Nginx_Configure} check_result $? make check_result $? make install check_result $? } install(){ echo -e "\e[0;44m <====Startting install Nginx====> \e[0m" root_or_not install_develop_tools download_nginx configure_install_nginx } install_or_not
本文出自 “不求最好,只求更好” 博客,请务必保留此出处http://yujianglei.blog.51cto.com/7215578/1725587
原文地址:http://yujianglei.blog.51cto.com/7215578/1725587