卷前:使用tomcat的时候可能会遇到某些问题,新手值得来看一眼。

1.配置完成进入manager需要密码?wtf?

在conf/tomcat-users.xml中按格式添加用户

默认是注释掉了的,主要是考虑到服务器的安全,输入完重启动服务器。

<role rolename=”tomcat”/>

<role rolename=”role1″/>

<user username=”tomcat” password=”tomcat” roles=”tomcat”/>

<user username=”both” password=”tomcat” roles=”tomcat,role1″/>

<user username=”role1″ password=”tomcat” roles=”role1″/>

2.进入manager界面之后,显示403 Access Denied。

在conf/tomcat-users.xml文件中看到这么一段话:

NOTE:  By default, no user is included in the “manager-gui” role required

to operate the “/manager/html” web application.  If you wish to use this app,

you must define such a user – the username and password are arbitrary.

也就是说,为了考虑安全,tomcat默认还是没有manager-gui的管理权限的,如果想要使用manager的话,需要自行加入管理权限(角色)。需要加一个这样的权限(角色)

<role rolename=”manager-gui”/>

然后再加到需要的用户名中去

<user username=”tomcat” password=”tomcat” roles=”tomcat,manager-gui”/>

搞定。

<tomcat-users>
<!–
NOTE: By default, no user is included in the “manager-gui” role required
to operate the “/manager/html” web application. If you wish to use this app,
you must define such a user – the username and password are arbitrary.
–>
<role rolename=”manager-gui”/>
<!–
NOTE: The sample user and role entries below are wrapped in a comment
and thus are ignored when reading this file. Do not forget to remove
<!.. ..> that surrounds them.
–>
<!–
<role rolename=”tomcat”/>
<role rolename=”role1″/>
<user username=”tomcat” password=”tomcat” roles=”tomcat”/>
<user username=”both” password=”tomcat” roles=”tomcat,role1″/>
<user username=”role1″ password=”tomcat” roles=”role1″/>
–>
<role rolename=”tomcat”/>
<role rolename=”role1″/>
<user username=”tomcat” password=”tomcat” roles=”tomcat,manager-gui”/>
<user username=”both” password=”tomcat” roles=”tomcat,role1″/>
<user username=”role1″ password=”tomcat” roles=”role1″/>
</tomcat-users>