Tomcat的Manager顯示403 Access Denied


管理tomcat的時候遇到了以下問題:

  1.剛開始需要用戶名密碼,不知道用戶名和密碼是什么,但是輸入什么都不正確。

  解決辦法:

  自己在tomcat-users.xml中按格式添加用戶 conf文件夾里面

  默認是注釋掉了的,這主要是考慮到服務器的安全,如果是本地測試,去掉以下這段注釋,然后重啟動服務器,再輸入

   <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"/>

  這樣OK了。

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<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.
-->
<!--
  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="manager-gui"/>
    <role rolename="admin-gui"/>
    <user username="ming" password="064417" roles="manager-gui,admin-gui"/>

</tomcat-users>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM