CentOS 安装tomcat
Posted 我是属车的
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 安装tomcat相关的知识,希望对你有一定的参考价值。
1、确保JDK已经安装,版本在1.8以上
2、到网管下载安装
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.14/bin/apache-tomcat-9.0.14.tar.gz tar -xzvf apache-tomcat-9.0.14.tar.gz
3、查看tomcat配置
[root@bigdata-senior01 bin]# ./catalina.sh version Using CATALINA_BASE: /opt/apache-tomcat-9.0.14 Using CATALINA_HOME: /opt/apache-tomcat-9.0.14 Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.14/temp Using JRE_HOME: /home/java/jdk1.8.0_172/jre Using CLASSPATH: /opt/apache-tomcat-9.0.14/bin/bootstrap.jar:/opt/apache-tomcat-9.0.14/bin/tomcat-juli.jar Server version: Apache Tomcat/9.0.14 Server built: Dec 6 2018 21:13:53 UTC Server number: 9.0.14.0 OS Name: Linux OS Version: 3.10.0-693.el7.x86_64 Architecture: amd64 JVM Version: 1.8.0_172-b11 JVM Vendor: Oracle Corporation
4、配置端口,开通防火墙端口
#可以选择修改默认的8080端口 [root@bigdata-senior01 apache-tomcat-9.0.14]# vi conf/server.xml <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <!-- A "Connector" using the shared thread pool--> <!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> 打开防火墙 [root@bigdata-senior01 bin]# firewall-cmd --add-port=8080/tcp --permanent success [root@bigdata-senior01 bin]# firewall-cmd --reload success
5、配置管理用户
[root@bigdata-senior01 apache-tomcat-9.0.14]# vi conf/tomcat-users.xml
#加入管理用户
<role rolename="manager-gui"/>
<user username="admin" password="123456" roles="manager-gui"/>
#修改管理页面的ip访问许可 [root@bigdata-senior01 apache-tomcat-9.0.14]# vi webapps/manager/META-INF/context.xml <Context antiResourceLocking="false" privileged="true" > <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192\\.\\d+\\.\\d+\\.\\d+|::1|0:0:0:0:0:0:0:1" /> #原本是127,即只允许本机访问 <Manager sessionAttributeValueClassNameFilter="java\\.lang\\.(?:Boolean|Integer|Long|Number|String)|org\\.apache\\.catalina\\.filters\\.CsrfPreventionFilter\\$LruCache(?:\\$1)?|java\\.util\\.(?:Linked)?HashMap"/> </Context>
6、测试tomcat
7、发布webapp
将war包或者整个webapp放入tomcat的webapps目录下即可访问,但是要跟上目录名,如果需要在ip或者域名后面直接访问,需要配置conf目录下的server.xml
[root@bigdata-senior01 apache-tomcat-9.0.14]# vi conf/server.xml ... ... <Host name="localhost" appBase="" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="/opt/apache-tomcat-9.0.14/webapps/bus" debug="0" privileged="true" />
以上是关于CentOS 安装tomcat的主要内容,如果未能解决你的问题,请参考以下文章