从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
完毕
评论