ubuntu安装tomcat8.5

下载压缩包
apache-tomcat-8.5.84.tar.gz
连接:https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.84/bin/apache-tomcat-8.5.84.tar.gz
1、创建目录:

sudo mkdir /usr/local/apache

2、进入/usr/lib/Tomcat文件夹,并解压tomcat:

sudo tar -zxvf apache-tomcat-8.5.84.tar.gz -C /usr/local/apache

3、进入Tomcat的bin目录,修改配置文件:

sudo vi startup.sh
sudo vi shutdown.sh

4、都在倒数第二行,增加以下内容:

JAVA_HOME=/usr/local/java/jdk1.8.0_351
JRE_HOME=${JAVA_HOME}/jre
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
TOMCAT_HOME=/usr/local/apache/apache-tomcat-8.5.84

5、启动Tomcat

sudo /usr/local/apache/apache-tomcat-8.5.84/bin/startup.sh

如果报错

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

打开/usr/local/apache/apache-tomcat-8.5.84/bin

sudo vim /usr/local/apache/apache-tomcat-8.5.84/bin/setclasspath.sh

添加

export JAVA_HOME=/usr/local/java/jdk1.8.0_351   
export JRE_HOME=/usr/local/java/jdk1.8.0_351/jre  

6、关闭Tomcat

sudo /usr/local/apache/apache-tomcat-8.5.84/bin/shutdown.sh

eclipse中配置如果启动不起来试试:
sudo chown -R 用户名 /usr/local/apache/apache-tomcat-8.5.84/*

7、关闭防火墙

systemctl status firewalld
# 查看转态
firewall-cmd --state
# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop 

8、eclipse中项目打war包


image.png

9、打好的war包放到tomcat中的webapp目录,它会自动解压


image.png

10、远程电脑浏览器可访问

你可能感兴趣的:(ubuntu安装tomcat8.5)