tomcat使用manager管理app時需要身份驗證問題


我們可以通過圖形用戶界面來管理tomcat,啟動tomcat,在地址欄中輸入:

Java代碼

  1. http://localhost:8080

就可以看見tomcat的歡迎頁面,點擊左邊的tomcat manager 就會出現一個對話框,需要輸入用戶名和密碼,當忘記最開始安裝tomcat時的用戶名和密碼時,我們可以通過以下方傑來解決: 
修改tomcat-users.xml文件,這個文件在tomcat的安裝目錄下的conf目錄下,打開這個文件,我們可以看到如下信息:

Java代碼

  1. <tomcat-users>
  2. <!--
  3. NOTE: By default, no user is included in the "manager-gui" role required
  4. to operate the "/manager/html" web application. If you wish to use this app,
  5. you must define such a user - the username and password are arbitrary.
  6. -->
  7. <!--
  8. NOTE: The sample user and role entries below are wrapped in a comment
  9. and thus are ignored when reading this file. Do not forget to remove
  10. <!.. ..> that surrounds them.
  11. -->
  12. <!--
  13. <role rolename="tomcat"/>
  14. <role rolename="role1"/>
  15. <user username="tomcat" password="tomcat" roles="tomcat"/>
  16. <user username="both" password="tomcat" roles="tomcat,role1"/>
  17. <user username="role1" password="tomcat" roles="role1"/>
  18. -->
  19. </tomcat-users>

我們在這里加上如下的一句話:

Java代碼

  1. <user username="admin" password="admin" roles="admin,manager"/>

修改后的文件為:

Java代碼

  1. <tomcat-users>
  2. <!--
  3. NOTE: By default, no user is included in the "manager-gui" role required
  4. to operate the "/manager/html" web application. If you wish to use this app,
  5. you must define such a user - the username and password are arbitrary.
  6. -->
  7. <!--
  8. NOTE: The sample user and role entries below are wrapped in a comment
  9. and thus are ignored when reading this file. Do not forget to remove
  10. <!.. ..> that surrounds them.
  11. -->
  12. <!--
  13. <role rolename="tomcat"/>
  14. <role rolename="role1"/>
  15. <user username="tomcat" password="tomcat" roles="tomcat"/>
  16. <user username="both" password="tomcat" roles="tomcat,role1"/>
  17. <user username="role1" password="tomcat" roles="role1"/>
  18. -->
  19. <user username="admin" password="admin" roles="admin,manager"/>
  20. </tomcat-users>

重新啟動tomcat服務器,這時,我們就可以使用用戶名為admin,密碼為admin的用戶登錄tomcat的管理界面了,這樣,我們可以遠程管理tomcat了

 

tomcat7 請添加如下文件:

<role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  
  <user username="admin" password="admin" roles="manager-gui,admin-gui"/>

 


免責聲明!

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



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