默认tomcat-user.xml中的角色和用户配置示例以下:html
<!--web
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
<user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
<user username="role1" password="<must-be-changed>" roles="role1"/>apache
-->tomcat
若是仅把上述内容去掉并修改密码,重启tomcat后访问http://localhost:8081/manager/html,会报403 Access Denied没法登陆管理界面。app
正确的配置以下:webapp
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="111111" roles="manager-gui,manager-script,manager-jmx,manager-status"/>ui
可是tomcat8.5 更改以后,仍然访问拒绝。xml
还需步骤以下:
vi /usr/local/tomcat/apache-tomcat-8.5.9/webapps/manager/META-INF/context.xmlhtm
缘由是tomcat8中定义了如下4种角色,因此配置文件中的角色名称是不能任意填写的。blog