一键源码安装ngxin

#!/bin/bash

nginxdir=nginx-1.16.1

nginx=/usr/local/nginx/sbin/nginx

author(){

echo "----------------------------------------------------------------------------------------------------"

echo "- nginx安装完毕 -"

echo "- 作者:lxl -"

echo "- 微信:l15565623507 -"

echo "----------------------------------------------------------------------------------------------------"

}

nginx_install(){

echo "解压nginx并安装nginx依赖环境中..."

echo "============================================="

tar -zxf nginx-1.16.1.tar.gz

yum -y install -q gcc gcc-c++ pcre-devel zlib-devel

echo "============================================="

echo "nginx编译"

echo "---------------------------------------------"

cd /usr/local/src/$nginxdir && ./configure && make && make install

echo "---------------------------------------------"

rm -rf $nginxdir

author

}

ss -ntlp|grep -q nginx

if [ $? -eq 0 ];then

echo "nginx已经存在"

else

cd /usr/local/src

if [ ! -e /usr/local/src/nginx-1.16.1 ];then

nginx_install

else

echo "nginx源码包下载中,请稍后......"

wget -q http://nginx.org/download/nginx-1.16.1.tar.gz

echo "下载完毕!"

nginx_install

author

fi

fi