首页 > 代码库 > CentOS7安装Tomcat8.X
CentOS7安装Tomcat8.X
安装说明
安装环境:CentOS7
安装方式:源码安装
软件:apache-tomcat-8.0.30.tar.gz
下载地址:http://tomcat.apache.org/download-80.cgi
安装前提
系统必须已经安装配置了JDK6+。(并且配置好环境变量)
安装tomcat
将apache-tomcat-8.0.30.tar.gz文件移动到/usr/local中执行以下操作:
[root@admin ~]# /usr/local/tomcat/bin/startup.sh
//启动tomcatUsing CATALINA_BASE:
/usr/local/tomcatUsing CATALINA_HOME:
/usr/local/tomcatUsing CATALINA_TMPDIR:
/usr/local/tomcat/tempUsing JRE_HOME:
/usr/java/jdk1.7.0/jreUsing CLASSPATH:
/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
启动Tomcat
执行以下操作:
Configure Tomcat-8[root@localhost ~]cd /usr/local/tomcat/bin
[root@localhost bin]cp catalina.sh /etc/init.d
[root@localhost tomcat7]cd /etc/init.d
[root@localhost init.d]mv catalina.sh tomcat
[root@localhost init.d]gedit tomcat
// 在#!/bin/bash下输入
# chkconfig: 2345 10 90
# description:Tomcat service
// 在#OS specific support................上输入
CATALINA_HOME=/usr/local//tomcat
JAVA_HOME=/usr/java/jdk1.6.0_38// 保存并退出文件
[root@localhost init.d]chmod +x tomcat
[root@localhost init.d]cd /
[root@localhost /]gedit /etc/profile// 在最后一行输入
#CATALINA_HOMECATALINA_HOME=/usr/local/tomcatexport CATALINA_HOME//保存并退出文件
[root@localhost /]source /etc/profile[3] Add tomcat to service list
[root@localhost /]chkconfig --add tomcat[4] Check service list
[root@localhost /]chkconfig --list tomcattomcat
0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭[5] Test tomcat service
[root@localhost /]service tomcat
--------------------Using CATALINA_BASE:
/tomcat8Using CATALINA_HOME:
/tomcat8Using CATALINA_TMPDIR:
/tomcat8/tempUsing JRE_HOME:
/usr/java/jdk1.7.0_25Using CLASSPATH:
/tomcat/bin/bootstrap.jar:/tomcat/bin/tomcat-juli.jar
Usage: catalina.sh ( commands ... )
. . . . .
--------------------[6] Start tomcat service
[root@localhost /]service tomcat start[7] OK!
出现以上的打印信息说明已经成功启动。
配置为 Linux Service
接下来Tomcat-8 配置为 Linux Service
Configure Tomcat-8[root@localhost ~]cd /usr/local/tomcat/bin[root@localhost bin]cp catalina.sh /etc/init.d[root@localhost tomcat7]cd /etc/init.d[root@localhost init.d]mv catalina.sh tomcat[root@localhost init.d]gedit tomcat// 在#!/bin/bash下输入# chkconfig: 2345 10 90# description:Tomcat service// 在#OS specific support................上输入CATALINA_HOME=/usr/local//tomcat JAVA_HOME=/usr/java/jdk1.6.0_38// 保存并退出文件[root@localhost init.d]chmod +x tomcat[root@localhost init.d]cd /[root@localhost /]gedit /etc/profile// 在最后一行输入#CATALINA_HOMECATALINA_HOME=/usr/local/tomcatexport CATALINA_HOME//保存并退出文件[root@localhost /]source /etc/profile[3] Add tomcat to service list[root@localhost /]chkconfig --add tomcat[4] Check service list[root@localhost /]chkconfig --list tomcattomcat 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭[5] Test tomcat service[root@localhost /]service tomcat --------------------Using CATALINA_BASE: /tomcat8Using CATALINA_HOME: /tomcat8Using CATALINA_TMPDIR: /tomcat8/tempUsing JRE_HOME: /usr/java/jdk1.7.0_25Using CLASSPATH: /tomcat/bin/bootstrap.jar:/tomcat/bin/tomcat-juli.jar Usage: catalina.sh ( commands ... ) . . . . . --------------------[6] Start tomcat service[root@localhost /]service tomcat start[7] OK!
防火墙开放8080端口
增加8080端口到防火墙配置中,执行以下操作:
[root@admin ~]# vi + /etc/sysconfig/iptables
增加以下代码
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
重启防火墙
[root@admin java]# service iptables restart
检验Tomcat安装运行
通过以下地址查看tomcat是否运行正常: http://127.0.0.1:8080/ 看到tomcat系统界面,恭喜,安装成功!
停止Tomcat
[root@admin ~]# /usr/local/tomcat/bin/shutdown.sh //停止tomcat
CentOS7安装Tomcat8.X