tomcat5 的管理功能

tomcat5.5的管理功能非常强,只要你配置好了tomcat-user.xml.

主要是增加一个 具有系统管理权限的用户,比如增加一个用户名和密码都是suxiaoyong的用户,只需要在在最后一行增加

代码
<user username="suxiaoyong" password="suxiaoyong" roles="admin,manager"/>



其 他的用户都可以删掉了

然后,我们可以进入http://localhost:8080/manager/status 来查看服务器的各种状态.

也可以通过url来直接对应用进行监控

命令格式

代码
http://{ host }:{ port }/manager/{ command }?{ parameters }



部 署一个应用

代码
http://localhost:8080/manager/deploy?path=/foo

http://localhost:8080/manager/deploy?path=/foo

http://localhost:8080/man......o&war=file:/path/to/foo

http://localhost:8080/manager/deploy?war=foo

http://localhost:8080/man......ath=/bartoo&war=bar.war



列 出已经部署的应用

代码
http://localhost:8080/manager/list



重 新加载一个应用


比如你更新了class或者lib的话,需要重新加载系统

代码
http://localhost:8080/manager/reload?path=/examples



查 看jvm和系统信息

代码
http://localhost:8080/manager/serverinfo



查 看可用的安全角色

代码
http://localhost:8080/manager/roles



查 看某个应用默认的session超时时间和当前活跃的session数

代 码
http://localhost:8080/manager/sessions?path=/examples



启 动一个应用

比如有时候重新启动数据库后可能需要重新启动应用

代 码
http://localhost:8080/manager/start?path=/examples



关 闭一个应用

关闭后,任何发往该应用的请求都将转向404错误的页面

代 码
http://localhost:8080/manager/stop?path=/examples


 
undeploy

慎 用,将删除应用的目录及其war文件

ant脚本,更多的详见tomcat5.5的文档

代码
<project name="My Application" default="compile" basedir=".">

 <!-- Configure the directory into which the web application is built -->
 <property name="build"    value="${ basedir }/build"/>

 <!-- Configure the context path for this application -->
 <property name="path"     value="/myapp"/>

 <!-- Configure properties to access the Manager application -->
 <property name="url"      value="http://localhost:8080/manager"/>
 <property name="username" value="myusername"/>
 <property name="password" value="mypassword"/>

 <!-- Configure the custom Ant tasks for the Manager application -->
 <taskdef name="deploy"    classname="org.apache.catalina.ant.DeployTask"/>
 <taskdef name="list"      classname="org.apache.catalina.ant.ListTask"/>
 <taskdef name="reload"    classname="org.apache.catalina.ant.ReloadTask"/>
 <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"/>
 <taskdef name="roles"     classname="org.apache.catalina.ant.RolesTask"/>
 <taskdef name="start"     classname="org.apache.catalina.ant.StartTask"/>
 <taskdef name="stop"      classname="org.apache.catalina.ant.StopTask"/>
 <taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"/>

 <!-- Executable Targets -->
 <target name="compile" description="Compile web application">
   <!-- ... construct web application in ${ build } subdirectory, and
           generated a ${ path }.war ... -->
 </target>

 <target name="deploy" description="Install web application"
         depends="compile">
   <deploy url="${ url }" username="${ username }" password="${ password }"
           path="${ path }" war="${ build }${ path }.war"/>
 </target>

 <target name="reload" description="Reload web application"
         depends="compile">
   <reload  url="${ url }" username="${ username }" password="${ password }"
           path="${ path }"/>
 </target>

 <target name="undeploy" description="Remove web application">
   <undeploy url="${ url }" username="${ username }" password="${ password }"
           path="${ path }"/>
 </target>

</project>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值