#!/bin/bash
#########################
#create by AL  2017/10/16
#########################

##支持环境安装
yum install -y gcc gcc-c++ perl

##添加用户和组
groupadd www -g 504
useradd -s /sbin/nologin -M www -u 504 -g 504

##下载安装包


soft_path=/root/software

if [ ! -d $soft_path ];then
	mkdir $soft_path
	cd $soft_path
else
	cd $soft_path
fi

wget http://47.90.101.26/linux/nginx/nginx.txt

if [ ! -f nginx-1.4.4.tar.gz ];then
	wget http://47.90.101.26/linux/nginx/nginx-1.4.4.tar.gz
fi

if  [ ! -f pcre-8.34.tar.gz ];then
wget http://47.90.101.26/linux/nginx/pcre-8.34.tar.gz
fi 

if  [ ! -f openssl-1.0.1c.tar.gz ];then
wget http://47.90.101.26/linux/nginx/openssl-1.0.1c.tar.gz
fi

if  [ ! -f zlib-1.2.8.tar.gz ];then
wget http://47.90.101.26/linux/nginx/zlib-1.2.8.tar.gz
fi

##解压

tar zxf pcre-8.34.tar.gz
tar zxf openssl-1.0.1c.tar.gz
tar zxf zlib-1.2.8.tar.gz
tar zxf nginx-1.4.4.tar.gz

cd  nginx-1.4.4

./configure --prefix=/opt/nginx \
--user=www --group=www \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--without-http_map_module \
--without-http_geo_module \
--with-http_flv_module \
--with-http_realip_module \
--with-pcre=/root/software/pcre-8.34 \
--with-zlib=/root/software/zlib-1.2.8 \
--with-http_ssl_module \
--with-openssl=/root/software/openssl-1.0.1c \
--with-debug 

make && make install


 


if [ $? == 0 ];then
printf  '''
########################
nginx  install success
########################
'''
else

echo "Please check error"
fi

cat /root/software/nginx.txt >/etc/rc.d/init.d/nginx


chmod +x /etc/rc.d/init.d/nginx
chkconfig --add nginx
chkconfig --level 2345 nginx on


