centos一键安装nginx

#!/bin/bash
select banben in nginx-1.6.3 nginx-1.7.3 nginx-1.8.1 nginx-1.9.9
do
if [[ -n $banben ]] ;then
break
fi
done
path_nginx="http://nginx.org/download/$banben.tar.gz"
nname=`echo $path_nginx | awk -F/ '{print $NF}'`
prefix="/home/$banben"
rpm_list[0]="pcre"
rpm_list[1]="openssl"
rpm_list[2]="openssl-devel"
rpm_list[3]="gcc"
rpm_list[4]="wget"
rpm_list[5]="pcre-devel"
rpm_list[6]="lsof"
for((i=0;i<${#rpm_list[*]};i++)){
rpmq=`rpm -qa ${rpm_list[$i]}`
if [[ -z $rpmq ]];then
echo "${rpm_list[$i]} ..........is not found"
echo "Start install ${rpm_list[$i]} "
yum -y install ${rpm_list[$i]}
else
echo "${rpm_list[i]} is OK !"
fi
}
temp=`mktemp -d`
cd $temp
wget $path_nginx
if [[ -e $nname ]];then
tar -xvzf $nname
cd nginx*
useradd nginx -s /sbin/nologin -M
./configure --user=nginx --group=nginx --prefix=$prefix --with-http_stub_status_module --with-http_ssl_module
make
make install
ln -s $banben /home/nginx
/home/nginx/sbin/nginx -t
cd /etc/init.d/
wget 45.34.66.172/linux/nginx/nginx.sh && mv nginx.sh nginx && chmod 777 nginx && sed -i 's/ $//' nginx
service nginx start
echo "+++++++++++++++++++++++++++++++++++++++"
echo "+ Nginx is start now +"
echo "+++++++++++++++++++++++++++++++++++++++"
lsof -i :80
else
echo "$nname is not found"
fi

原文地址:https://www.cnblogs.com/uyahs/p/7670404.html