Tomcat 5.5实用工具Tomcat Web Server Administration Tool运行于Web环境,通过浏览器可以非常方便地进行Tomcat服务器的配置,如图所示:
但是,Tomcat 5.5 以后的binary Core安装版不再提供Tomcat Web Server Administration Tool,如若要使用该实用工具,必须从http://tomcat.apache.org/下载Administration Web Application压缩包,且需要在本地进行配置。
一、下载文件apache-tomcat-5.5.27-admin.zip
二、将文件apache-tomcat-5.5.27-admin.zip解压到目录F:/Tomcat/apache-tomcat-5.5.27。
apache-tomcat-5.5.27目录内容为:
到此,实用工具Tomcat Web Server Administration Tool的应用程序Administration Web Application只是存在本地,还没有被发布到Tomcat服务器中,所以通过访问http://localhost:8080/admin得到的结果如下:
Tomcat's administration web application is no longer installed by default. Download and install the "admin" package to use it.
现在开始在Tomcat中配置Administration Web Application :
三、将文件apache-tomcat-5.5.27/conf/Catalina/localhost/ admin.xml拷贝到Tomcat服务器所在安装目录E:/j2ee/Tomcat 5.5/conf/Catalina/localhost目录。
admin.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.
-->
<!--
Context configuration file for the Tomcat Administration Web App
$Id: admin.xml 565211 2007-08-13 00:09:38Z markt $
-->
<Context docBase="${catalina.home}/server/webapps/admin" privileged="true"
antiResourceLocking="false" antiJARLocking="false">
<!-- Uncomment this Valve to limit access to the Admin app to localhost
for obvious security reasons. Allow may be a comma-separated list of
hosts (or even regular expressions).
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127.0.0.1"/>
-->
</Context>
四、将apache-tomcat-5.5.27/server/webapps目录下的admin目录整个拷贝到Tomcat服务器所在安装目录E:/j2ee/Tomcat 5.5/server/webapps目录。
五、编辑文件E:/j2ee/Tomcat 5.5/conf/ tomcat-users.xml,为该实用工具程序添加用户zhans信息。
tomcat-users.xml具体内容:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="admin" password="admin" roles="admin,manager"/>
<user username="zhans" password="nice" roles="admin,manager"/>
</tomcat-users>
注意:username/password任意组合,但roles=“admin”角色不可随意改动!
六、重启Tomcat服务器,访问URL : http://localhost:8080/admin,验证通过后,即可使用实用工具Tomcat Web Server Administration Tool。