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>
發佈了116 篇原創文章 · 獲贊 34 · 訪問量 17萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章