加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell脚本自动安装nginx

发布时间:2020-12-15 23:01:45 所属栏目:安全 来源:网络整理
导读:写一脚本,实现对nginx的自动化下载,安装,启动,停止 ? #!/bin/sh ###nginx install shell SOFT_PATH=/data/soft NGINX_FILE=nginx-1.14.2.tar.gz DOWN_PATH=http://nginx.org/download/ if [ $# -ne 1 ];then echo "USAAGE:$0{download or start or insta

写一脚本,实现对nginx的自动化下载,安装,启动,停止

?

#!/bin/sh

###nginx install shell

SOFT_PATH=/data/soft
NGINX_FILE=nginx-1.14.2.tar.gz
DOWN_PATH=http://nginx.org/download/

if [ $# -ne 1 ];then

echo "USAAGE:$0{download or start or install or stop}"

exit 0

fi

if [ $UID -ne 0 ];then
echo this script must use administrator or root user.please exit!
sleep 2
exit 1
fi

if [ ! -d $SOFT_PATH ];then
mkdir -p $SOFT_PATH
mkdir -p /application/nginx1.14.2
fi

download()
{
cd $SOFT_PATH;wget $DOWN_PATH/$SOFT_FILE
}

install()
{
yum install -y pcre pcre-devel openssl openssl-devel
cd $SOFT_PATH;tar xf $NGINX_FILE;cd nginx-1.14.2/ && ./configure --with-http_stub_status_module --with-http_ssl_module --prefix=/application/nginx1.14.2
[ $? -eq 0 ] && make && make install
ln -s /application/nginx1.14.2/ /application/nginx
}

start()
{
`netstat -lntp|grep 80`[ $? -ne 0 ] && /application/nginx/sbin/nginx
}

stop()
{
ps -ef|grep nginx|grep -v grep|awk ‘{print $2}‘|xargs kill -9
}

case $1 in
download)
download
;;

install)

install

;;

start) start ;; stop) stop ;; *) echo "USAAGE:$0{download or start or install or stop}" exitesac

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读