大佬教程收集整理的这篇文章主要介绍了CentOS 安装tomcat,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
1、确保JDK已经安装,版本在1.8以上
2、到网管下载安装
wget http://@H_533_10@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配置
[[email protected] 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端口 [[email protected]-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" /> --> 打开防火墙 [[email protected]-senior01 bin]# firewall-cmd --add-port=8080/tcp --peRMANent success [[email protected]-senior01 bin]# firewall-cmd --reload success
5、配置管理用户
[[email protected] apache-tomcat-9.0.14]# vi conf/tomcat-users.xml #加入管理用户 <role rolename="manager-gui"/> <user username="admin" password="123456" roles="manager-gui"/>
#修改管理页面的ip访问许可 [[email protected]-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
以上是大佬教程为你收集整理的CentOS 安装tomcat全部内容,希望文章能够帮你解决CentOS 安装tomcat所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。