nginx 脚本安装

#!/bin/bash
#nginx service 搭建
#autor :elin
###关闭防火墙安全机制####
iptables -F
setenforce 0
systemctl stop firewalld
echo "防火墙安全机制已关闭。。"
###安装必要的安装包#####
yum -y install  pcre-devel zlib-devel openssl-devel &>/dev/null
if [ $? -eq 0 ]
then
 echo "安装包已经安装。。"
else
 echo "安装失败。。"
fi
while :
do
read -p "请上传nginx安装包,如果已经上传过,请输入数字1: " a
if [ $a -ne 1 ]
then
    echo "未上传nginx安装包,请上传后在进行服务搭建。。"
 break
else
 echo "nginx安装包已经上传,正在进行服务搭建"
 [ -f /home/nginx ]||useradd -M -s /sbin/nologin nginx
 tar xf ngnix-1.14.2.tar.gz -C /usr/src/
 ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module &>/dev/null
 make &>/dev/null && make install &>/dev/null
 echo "编译配置完成。。"
 ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/ &>/dev/null
 nginx -t
 echo "nginx安装成功."
 nginx
 echo "服务已经打开.请输入netstat -anpt | grep :80进行检测服务是否开启.."
 break
fi
done
原文地址:https://www.cnblogs.com/elin989898/p/11852184.html