#!/bin/bash

if [ $1 ] 
then
    if [ ! -d "$1"]
    then
        echo “this is not a  PATH”
        exit 1
    else
        basedir=$1
    fi
else
    basedir=/usr/local/nginx
fi

pkill nginx

yum install -y gcc gcc-c++ make libtool                                       
yum install -y zlib zlib-devel pcre pcre-devel openssl-devel                       
yum install -y perl-devel perl-ExtUtils-Embed perl-WWW-Curl

cd /home
wget https://nginx.org/download/nginx-1.19.3.tar.gz --no-check-certificate
tar -xvf nginx-1.19.3.tar.gz
cd nginx-1.19.3
./configure \
--prefix=$basedir \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gzip_static_module \
--with-http_perl_module \
--with-pcre \
--with-cc-opt=-fPIC 
make -j60
make install


if [ ! -d "$basedir" ]; then
  echo "Nginx  1.19.3 Install Result Faild"
else
  echo "Nginx  1.19.3 Install Result success"
fi



