我們可以通過圖形用戶界面來管理tomcat,啟動tomcat,在地址欄中輸入:
Java代碼
- http://localhost:8080
就可以看見tomcat的歡迎頁面,點擊左邊的tomcat manager 就會出現一個對話框,需要輸入用戶名和密碼,當忘記最開始安裝tomcat時的用戶名和密碼時,我們可以通過以下方傑來解決:
修改tomcat-users.xml文件,這個文件在tomcat的安裝目錄下的conf目錄下,打開這個文件,我們可以看到如下信息:
Java代碼
- <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"/>
- -->
- </tomcat-users>
我們在這里加上如下的一句話:
Java代碼
- <user username="admin" password="admin" roles="admin,manager"/>
修改后的文件為:
Java代碼
- <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"/>
- -->
- <user username="admin" password="admin" roles="admin,manager"/>
- </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"/>