almalinux8安装tomcat9

王忘杰
2023-08-03 / 0 评论 / 138 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2023年08月03日,已超过479天没有更新,若内容或图片失效,请留言反馈。

从yum源直接安装tomcat9

yum install tomcat tomcat-webapps tomcat-admin-webapps

启动服务

systemctl enable --now tomcat

访问tomcat正常
http://IP:8080/

配置Manager App访问范围
/usr/share/tomcat/webapps/manager/META-INF/context.xml

原内容
<Context antiResourceLocking="false" privileged="true" >
  <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                   sameSiteCookies="strict" />
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
增加任意IP访问 \d+\.\d+\.\d+\.\d+ 
修改后
<Context antiResourceLocking="false" privileged="true" >
  <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                   sameSiteCookies="strict" />
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|\d+\.\d+\.\d+\.\d+" />
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>

配置Manager App用户名密码
/usr/share/tomcat/conf/tomcat-users.xml

在倒数第二行添加
  <role rolename="manager-gui"/>
  <user username="admin" password="admin" roles="manager-gui"/>

重启服务

systemctl restart tomcat

完毕
lkushvqg.png

0

评论

博主关闭了所有页面的评论