linux使用shell一键安装tomcat 并更改访问端口为 80
2018-03-16 11:08
721 查看
#!/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
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
相关文章推荐
- linux下使用apache http server 连接 tomcat 达到使用直接apache一个服务端口就可访问php和jsp
- linux使用shell一键安装jdk
- MySql使用小结:允许远程访问、更改最大连接数、VARCHAR字段占用的空间、linux下安装workbench
- linux使用shell一键安装mysql
- Linux一键安装tomcat的shell脚本
- linux下如何将tomcat的监听端口改为80
- 使用Python2.4在Linux下访问SQL Server(安装篇)
- 安装、设置和使用SSH Secure shell 实现windows 登录linux
- LINUX下使用Shell自动监控tomcat并且执行重启操作
- Jsp和PHP共用80端口整合Apache和Tomcat(访问时无需加端口号)
- linux下jdk、tomcat的安装及项目的部署和去掉项目名访问详细总结
- LINUX下使用Shell自动监控tomcat并且执行重启操作
- 使用Python2.4在Linux下访问SQL Server(安装篇)
- centOS 防火墙 添加TOMCAT访问端口 查看是否安装mysql
- Linux系统非ROOT用户80端口不能启动tomcat问题的变通办法——通过Iptables端口转发
- 安装后手动更改 XML Service 端口,以便使用不同于 IIS 的端口
- Linux系统非ROOT用户80端口不能启动tomcat问题的变通办法——通过Iptables端口转发
- Linux中使用Msmtp+mutt+shell自动发邮件程序安装说明
- Linux上安装配置使用Tomcat说明文档和JDK环境变量配置
- 安装jira同时又需要使用tomcat时端口问题