linux使用shell一键安装tomcat 并更改访问端口为 80

#!/bin/sh
sduo su

sofeware_file="/home/sofeware"
tomcat_dir="/usr/local/webserver/tomcat"
get_tomcat_url=https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.79/bin/apache-tomcat-7.0.79.tar.gz
# $1 传入的第一个参数(获取安装包的远程路径)
if [ ! -n "$1" ];then
 get_tomcat_url=$1
fi
# $2 传入的第二个参数 (安装目录)
if [ ! -n "$2" ];then
  tomcat_dir=$2
fi

if [ ! -d "${sofeware_file}" ];then
  mkdir -p ${sofeware_file}
fi

# create tomcat file
if [ ! -d "$tomcat_dir" ];
then
 mkdir $tomcat_dir
fi

cd $sofeware_file

tomcat_file=$(find `dirname $sofeware_file` -name *tomcat*.tar.gz)
# 远程获取
if [ ! -e "$tomcat_file" ];
then
  wget $get_tomcat_url
  if [ $? -ne 0 ];then
   read -p "Remote access failed, do you use default address access?(y/n) " name
   if [ "y" = "$name" ];then
    wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.79/bin/apache-tomcat-7.0.79.tar.gz
    if [ $? -ne 0 ];then
     echo "Remote access to tomcat installation package failed!"
     exit 0
    fi
   else
     exit 0
   fi
  fi
fi
# 查找文件
tomcat_file=$(find `dirname $sofeware_file` -name *tomcat*.tar.gz)
# 解压
tar -zxvf ${tamcat_file##*/} -C ${tomcat_dir}
# 获取文件夹名称
wj_file=$(ls $tomcat_dir/ -l| awk '/^d/{print $NF}')
wj_new_file=${tomcat_dir}/${wj_file}
# 修改端口为 80
sed -i 's/8080/80/' $wj_new_file/conf/server.xml

cd $wj_new_file/bin
# 赋权
chmod u+x *.sh
# 启动
./startup.sh
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值