基于centos7.5安装tomcat

作者阿里云代理 文章分类 分类:linux图文教程 阅读次数 已被围观 971

基于centos7.5安装tomcat
1.将所需安装包导入服务器内,然后解压
环境依赖包:jdk-8u151-linux-x64.tar
解压jdk
tar xvf jdk-8u151-linux-x64.tar.gz -C /usr/local/
mv /usr/local/jdk-8u151 /usr/local/java

添加环境变量,文件位置vim /etc/profile
JAVA_HOME=/usr/local/java
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib/dt.jar
export JAVA_HOME JRE_HOME PATH CLASSPATH

重置环境变量,使生效
source /etc/profile

查看java版本
[root@localhost ~]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

2.安装apache-tomcat
解压Tomcat
mkdir /usr/local/tomcat
tar xvf apache-tomcat-8.5.39.tar.gz -C /usr/local/tomcat
cd /usr/local/tomcat/apache-tomcat-8.5.39

添加环境变量,位置vim /etc/profile 添加如下内容
TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-8.5.39
CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.5.39
CATALINA_BASE=/usr/local/tomcat/apache-tomcat-8.5.39
export TOMCAT_HOME CATALINA_HOME CATLAINA_BASE

重置使之生效
source /etc/profile

配置主命令脚本
cd /usr/local/tomcat/apache-tomcat-8.5.39/bin
vim catalina.sh

输入查找:

/OS specific support

插入两行:

export CATALINA_BASE=$CATALINA_BASE
export CATALINA_HOME=$CATALINA_HOME


说明:以上环境变量也可以执行多个tomcat,示例如下: ==tomcat-xxxx(版本或自定义名)== TOMCAT_HOME_2=/usr/local/tomcat-251/apache-tomcat-8.5.39 CATALINA_HOME_2=/usr/local/tomcat-251/apache-tomcat-8.5.39 CATALINA_BASE_2=/usr/local/tomcat-251/apache-tomcat-8.5.39 export TOMCAT_HOME_2 CATALINA_HOME_2 CATLAINA_BASE_2
3.启动tomcat
cd /usr/local/tomcat/apache-tomcat-8.5.39/bin
./startup.sh

本公司销售:阿里云新/老客户,只要购买阿里云,即可享受折上折优惠!>

我有话说: