环境准备
准备一台Centos6服务器
系统: Centos6.8
内存:1G
cpu: 2核
IP地址: 10.0.0.22
Tomcat包路径
https://tomcat.apache.org/download-80.cgi
jdk包路径
https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html
首先上传包至服务器
# 创建脚本文件
vim tomcat.sh
#!/bin/bash
IP=$(ifconfig eth0 | awk '/Mask/{print $2}' | awk -F ':' '{print $2}')
rpm -ivh jdk-8u131-linux-x64_.rpm
echo "export JAVA_HOME=/usr/java/jdk1.8.0_131" >> /etc/profile
echo "export PATH=$PATH:$JAVA_HOME/bin" >> /etc/profile
source /etc/profile
tar zxf apache-tomcat-8.5.35.tar.gz -C /opt/
mv /opt/apache-tomcat-8.5.35 /opt/tomcat
/opt/tomcat/bin/startup.sh
echo "tomcat部署完毕,请访问:http://$IP:8080"
# 关闭防火墙和selinux
service iptables stop
setenforce 0
# 执行脚本
sh tomcat.sh
测试访问页面…