tomcat 登录用户名 与 密码设置

来源:互联网 发布:用php做一个表格 编辑:程序博客网 时间:2024/05/21 21:34
401 UnauthorizedYou are not authorized to view this page. If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above.<role rolename="manager-gui"/><user username="tomcat" password="s3cret" roles="manager-gui"/>Note that for Tomcat 6.0.30 onwards, the roles required to use the manager application were changed from the single manager role to the following four roles. You will need to assign the role(s) required for the functionality you wish to access.manager-gui - allows access to the HTML GUI and the status pagesmanager-script - allows access to the text interface and the status pagesmanager-jmx - allows access to the JMX proxy and the status pagesmanager-status - allows access to the status pages onlyThe HTML interface is protected against CSRF but the text and JMX interfaces are not. To maintain the CSRF protection:The deprecated manager role should not be assigned to any user.Users with the manager-gui role should not be granted either the manager-script or manager-jmx roles.If the text or jmx interfaces are accessed through a browser (e.g. for testing since these interfaces are intended for tools not humans) then the browser must be closed afterwards to terminate the session.For more information - please see the Manager App HOW-TO.

在使用Tomcat时,我们通过点击Tomcat Manager (如下图左侧所示)可以管理Tomcat服务器中的web工程;但是如何来设置用户名还有密码呢?看接下来的介绍:


Solutions:

1、登录用户名和密码我们需要在 目录:D:\apache-tomcat-6.0.35\conf\tomcat-users.xml 中修改如下配置:

<tomcat-users>    <role rolename="manager"/>   <user username="admin" password="admin" roles="manager"/> </tomcat-users>
2、进入当前目录下的:context.xml 文件,并作如下修改

<?xml version="1.0" encoding="UTF-8"?>    <WatchedResource>WEB-INF/web.xml</WatchedResource>    <Manager pathname="/manager" debug="0"  privileged="true" docBase="/home/oracle/tomcat/apache-tomcat-6.0.18/webapps/manager" />        <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />  </Context>

完成这两部之后,重新启动一个tomcat ,即可输入刚才设置的用户名和密码,即可登录Tomcat 管理web project。




原创粉丝点击