tomcat 远程部署
tomcat 的管理功能非常强,只要你配置好了tomcat-user.xml.
主要是增加一个 具有系统管理权限的用户,比如增加一个用户名和密码都是admin的用户,只需要在在最后一行增加
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<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"/>
然后,我们可以进入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>