管理tomcat的時候遇到了如下問題:html
1.剛開始須要用戶名密碼,不知道用戶名和密碼是什麼,可是輸入什麼都不正確。web
解決辦法:express
本身在tomcat-users.xml中按格式添加用戶 conf文件夾裏面apache
默認是註釋掉了的,這主要是考慮到服務器的安全,若是是本地測試,去掉如下這段註釋,而後重啓動服務器,再輸入tomcat
<role rolename="tomcat"/>安全
<role rolename="role1"/>服務器
<user username="tomcat" password="tomcat" roles="tomcat"/>app
<user username="both" password="tomcat" roles="tomcat,role1"/>less
<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="tomcat"/> <user username="tomcat" password="tomcat" roles="manager-gui,tomcat"/> </tomcat-users>