nginx脚本自动安装

nginx脚本自动安装

脚本功能:

  1. 自动安装nginx
  2. 自动判别系统是否安装nginx
  3. 自定义安装nginx路径
  4. 自定义安装nginx版本。
#!/bin/bash
#2019年10月30日16:00:50
#auto install nginx web
#by author sunjinhua
########################
NGX_USR="www"
NGX_VER="$1"
NGX_YUM="yum install -y"
NGX_SRC="nginx-${NGX_VER}"
NGX_DIR="$2"
NGX_URL="http://nginx.org/download"
NGX_SOFT="${NGX_SRC}.tar.gz"
NGX_ARGS="--user=$NGX_USR --group=$NGX_USR --with-http_stub_status_module"
if [ $# -ne 2]; then
	echo -e "\03332m------------------------------\033[0m"
	echo -e "\03332musage:{/bin/sh $0 1.160 /usr/local/nginx/ }\033[0m"
  	exit
fi
if [ ! -d "$NGX_DIR" ];then
 	cd $HOME
	$NGX_YUM wget gzip tar make gcc
	$NGX_YUM pcre pcre-devel zlib-devel openssl-devel
	wget -c $NGX_URL/$NGX_SOFT
	ls -l   $NGX_SOFT 
	tar -xzf $NGX_SOFT 
	cd $NGX_SRC 
	useradd -s /sbin/nologin $NGX_USR -M
	./configure --prefix=$NGX_DIR $NGX_ARGS 
if [ $? -eq 0 ];then
	make
else
	echo  "please chenck nginx error"
fi
if [ $? -eq 0 ];then
	make install
else
	echo "plase chenck install nginx error"
fi
	$NGX_DIR/sbin/nginx
	ps -ef|grep nginx
	netstat -tnlp|grep 80
	setenforce 0
	systemctl stop firewalld.service
fi

posted @   骑马挎枪打天下  阅读(353)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示