tomcat manager用户密码

tomcat manager 用户密码
在http://tomcat.apache.org/下载的jakarta-tomcat-5.0.28.zip解压配置好之后启动,可以正常显示http://127.0.0.1:8080/index.jsp

打开tomcat主目录下的子目录conf里面的tomcat-users.xml文件,用户配置内容如下:
<tomcat-users>
<user name="tomcat" password="tomcat" roles="tomcat" />
<user name="role1" password="tomcat" roles="role1" />
<user name="both" password="tomcat" roles="tomcat,role1" />
</tomcat-users>


当点击主页上的连接想进入管理界面的时候,我试着用文件里面提到的用户名和密码登陆,得到的却是:
HTTP Status 403 - Access to the requested resource has been denied

访问被拒绝。难道说这些用户都没有管理员的资格,那管理员的用户名和密码怎么知道呢?

仔细再看了tomcat-users.xml,发现其中提到:
<!--
NOTE: By default, no user is included in the "manager" role required
to operate the "/manager" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary.
-->

才恍然大悟。接下来,根据上面那段文字的意思,修改tomcat-users.xml文件,在其中添加管理员角色(manager),以及管理员用户(admin)和密码(admin),修改后如下:
<tomcat-users>
<role rolename="manager"/>
<user name="tomcat" password="tomcat" roles="tomcat" />
<user name="role1" password="tomcat" roles="role1" />
<user name="both" password="tomcat" roles="tomcat,role1" />
<user username="admin" password="admin" roles="manager"/>
</tomcat-users>

最后,重启tomcat,在进入管理页面的时候,用管理员用户admin和密码admin,登陆ok。

猜你喜欢

转载自z-jianwen.iteye.com/blog/1026074