Ubuntu安装Tomcat
Tomcat安装
一、安装tomcat
1.下载apache-tomcat-8.5.35.tar.gz
2.解压到安装目录,如:/usr/share
3.配置环境变量
修改/etc/profile,在末尾追加内容:
#tomcat
export TOMCAT_HOME=/usr/share/apache-tomcat-8.5.35
4.查看tomcat依赖的JDK版本
#vi /usr/share/apache-tomcat-8.5.35/RUNNING.txt
=============================
Running With JRE 7 Or Later
=============================
(1) Download and Install a Java SE Runtime Environment (JRE)
(1.1) Download a Java SE Runtime Environment (JRE),
release version 7 or later, from
http://www.oracle.com/technetwork/java/javase/downloads/index.html
(1.2) Install the JRE according to the instructions included with the
release.
You may also use a full Java Development Kit (JDK) rather than just
a JRE.
可以看到,建议安装JDK7以上的版本,且不能只装JRE
二、安装JDK
1.下载JDK包jdk-11.0.1_linux-x64_bin.tar.gz
2.解压到安装目录下即可,如/usr/share
3.设置环境变量
修改/etc/profile,在末尾追加内容:
#set Java environment
export JAVA_HOME=jdk安装目录
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
然后执行命令:
#source /etc/profile
4.查看java版本
#java -version
三、测试tomcat:
1.执行开启脚本(保证8080断开没有被占用):
#/usr/share/apache-tomcat-8.5.35/bin/startup.sh
2.在浏览器输入:http://127.0.0.1:8080打开成功说明tomcat成功启动
4.设置软件链接支持
tomcat默认不支持软链接,如果要支持的话,需要修改conf/context.xml
tomcat567版本:
<Context allowLinking="true" />
tomcat89版本:
<Context >
<Resources allowLinking="true" />
...
</Context>