centos7配置tomcat8详细图文步骤
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7配置tomcat8详细图文步骤相关的知识,希望对你有一定的参考价值。
环境描述:
centos7最小安装,配置tomcat8
1.可用本地电脑下载jdk1.8
官网如下,或需要注册Oracle账号登录后才可下载
https://www.oracle.com/technetwork/java/javase/downloads/index.html
2.安装上传工具
[[email protected] ~]# yum -y install lrzsz
上传jdk[[email protected] ~]# rz
3.jdk上传OK后解压
[[email protected] ~]# ls
anaconda-ks.cfg jdk-8u201-linux-i586.tar.gz
[[email protected] ~]# tar xf jdk-8u201-linux-i586.tar.gz
[[email protected] ~]# ls
anaconda-ks.cfg jdk1.8.0_201 jdk-8u201-linux-i586.tar.gz
[[email protected] ~]# mkdir -p /usr/local/
bin/ etc/ games/ include/ lib/ lib64/ libexec/ sbin/ share/ src/
[[email protected] ~]# mkdir /usr/local/java
[[email protected] ~]# mv jdk1.8.0_201/* /usr/local/java/
4.jdk环境变量配置
[[email protected] ~]# vim /etc/profile #追加如下变量
export JAVA_HOME=/usr/local/java
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
5.更新profile文件
[[email protected] ~]# source /etc/profile
6.查看java版本
[[email protected] local]# java -version
-bash: /usr/local/java/bin/java: /lib/ld-linux.so.2: bad ELF interpreter: 没有那个文件或目录
出错了:提示没有文件。
此情况应该是最小安装系统缺少相应的库文件导致出错
这里可根据提示安装相应的库文件即可[[email protected] ~]# yum -y install ld-linux.so.2
[[email protected] ~]# java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) Client VM (build 25.201-b09, mixed mode)
[[email protected] ~]# javac -version
javac 1.8.0_201
安装完提示缺少的文件后,再次查看Java版本,OK。
7.下载tomcat8
官网地址 https://tomcat.apache.org/download-80.cgi
依然下载到本地后再rz上传
8.上传tomcat8并解压
[[email protected] ~]# rz
[[email protected] ~]# ls
anaconda-ks.cfg apache-tomcat-8.5.41.tar.gz jdk1.8.0_201 jdk-8u201-linux-i586.tar.gz
[[email protected] ~]# tar xf apache-tomcat-8.5.41.tar.gz
[[email protected] ~]# ls
anaconda-ks.cfg apache-tomcat-8.5.41 apache-tomcat-8.5.41.tar.gz jdk1.8.0_201 jdk-8u201-linux-i586.tar.gz
[[email protected] ~]# mkdir /usr/local/tomcat8
[[email protected] ~]# mv apache-tomcat-8.5.41/* /usr/local/tomcat8/
9.启动tomcat
[[email protected] ~]# /usr/local/tomcat8/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat8
Using CATALINA_HOME: /usr/local/tomcat8
Using CATALINA_TMPDIR: /usr/local/tomcat8/temp
Using JRE_HOME: /usr/local/java
Using CLASSPATH: /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar
Tomcat started.
[[email protected] ~]# ps -ef|grep java
root 9744 1 31 16:44 pts/0 00:00:03 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/tomcat8/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat8 -Dcatalina.home=/usr/local/tomcat8 -Djava.io.tmpdir=/usr/local/tomcat8/temp org.apache.catalina.startup.Bootstrap start
root 9787 7172 0 16:44 pts/0 00:00:00 grep --color=auto java
启动完成,查看进程OK。
10.页面验证
http://192.168.0.64:8080/
此为防火墙在开启状态,访问被阻,关闭防火墙或者允许页面端口通过都可以。
实验环境可关闭防火墙:
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
生产环境建议开启端口即可,增强服务器安全性:
[[email protected] tomcat8]# firewall-cmd --permanent --add-port=8080/tcp
success
[[email protected] tomcat8]# firewall-cmd --reload
success
久违的tomcat页面显示OK。
以上是关于centos7配置tomcat8详细图文步骤的主要内容,如果未能解决你的问题,请参考以下文章