歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

Tomcat用戶名問題

在tomcat 7 免安裝版本中,用戶名和密碼默認都是沒有啟用的,需要我們手動在tomcat-users.xml文件裡指定(在conf文件夾下),這個文件裡面已經寫好了一些賬號的信息,只是默認的是注釋了而已,取消注釋之後,用這個文件提供的用戶名和密碼去訪問的時候,會出現403錯誤,這是因為我們沒有指定用戶所擁有的權限的原因、如我們現在想訪問tomcat中的圖形化管理應用的功能,也就是Manager App,我們就需要指定manager-gui的權限,想訪問host manager 就必須指定admin-gui權限等。下面是一個可用的tomcat-users.xml文件。

<?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="admin-gui"/>     
  <role rolename="manager-gui"/> 
  <user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/> 
 
</tomcat-users> 
<?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="admin-gui"/>   
  <role rolename="manager-gui"/>
  <user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/>

</tomcat-users>
 

摘自 snoopy的專欄
Copyright © Linux教程網 All Rights Reserved