tomcat+jdk安装
Posted 春分拂柳
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tomcat+jdk安装相关的知识,希望对你有一定的参考价值。
一、下载jdk
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
下载tomcat
http://tomcat.apache.org/download-80.cgi
2、安装jdk
yum install glibc.i686 mkdir -p /usr/java tar xf jdk-8u201-linux-x64.tar.gz -C /usr/java
3、配置环境变量
vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_201 export JAVA_PATH=$JAVA_HOME export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
生效
source /etc/profile
4、验证
[root@tomcat ~]# java -version java version "jdk1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) Client VM (build 25.191-b12, mixed mode)
5、安装tomcat
tar xf apache-tomcat-8.5.35.tar.gz -C /usr/local/ cd /usr/local/ mv apache-tomcat-8.5.35 tomcat
6、设置开启自启动
(1)方法一
cp -p /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat vim /etc/init.d/tomcat 第二行添加 # chkconfig: 112 63 37 # description: tomcat server init script # Source Function Library . /etc/init.d/functions JAVA_HOME=/usr/local/jdk1.8.0_191/ CATALINA_HOME=/usr/local/tomcat/
修改setclasspath.sh这个文件(不然会报错)
vim /usr/local/tomcat/bin/setclasspath.sh (添加两行)
export JAVA_HOME=/usr/java/jdk1.8.0_191
export JAVA_HOME=/usr/java/jdk1.8.0_191/jre
添加完了以后
chmod 755 /etc/init.d/tomcat
chkconfig --add tomcat
chkconfig tomcat on
(2)方法二
添加文件
vim /lib/systemd/system/tomcat.service [Unit] Description=Tomcat After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=oneshot ExecStart=/usr/local/tomcat/bin/startup.sh ExecStop=/usr/local/tomcat/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.target
修改文件
vim /usr/local/tomcat/bin/setclasspath.sh (添加两行)
export JAVA_HOME=/usr/java/jdk1.8.0_191
export JAVA_HOME=/usr/java/jdk1.8.0_191/jre
设置开机自启
systemctl enable tomcat.service
6、启动tomcat
/etc/init.d/tomcat start 或者 systemctl start tomcat.service
访问 ip+8080端口访问
7、tomcat启动慢(解决办法)
yum install rng-tools # 安装rngd服务(熵服务,增大熵池)
systemctl start rngd # 启动服务
以上是关于tomcat+jdk安装的主要内容,如果未能解决你的问题,请参考以下文章