如何通过终端命令将Web应用程序部署到tomcat应用程序服务器 [英] How can I deploy a web application to tomcat application server via Terminal command

查看:57
本文介绍了如何通过终端命令将Web应用程序部署到tomcat应用程序服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在测试大量的Web服务.我想通过终端命令尽快部署和取消部署到tomcat应用服务器.对于需要部署的大量Web服务,使用HTML GUI是不合理的.谁能协助我,如何通过终端命令进行部署?

I am currently testing a large number of webservices. I would like to deploy and undeploy to tomcat application server via terminal command as fast as I can. Using the HTML GUI would not be reasonable for the large number of webservices that I need to deploy. Can anyone assist me, in how to deploy via a terminal command?

此外,我正在编写一个自动执行部署过程的ash脚本,因此,如果有人可以给我一些指导,那就太好了.

Furthermore, I am writing a ash script that automates the deployment process, so perhaps if someone can give me some some direction it would be great.

理想情况下,我希望在命令行上执行以下操作:

Ideally, I am looking to do something like this on the command line:

TOMCAT --parameter指定WAR文件的路径--parameter2-指定某种配置文件

TOMCAT --parameter Specify path to WAR file --parameter2 --specify some sort of config file

推荐答案

首先,您需要确保

First you need to make sure that tomcat-user.xml is configured with the correct users and roles. The minimum role configuration is "admin,manager-script":

  1. 找出tomcat的安装位置.您可以在bash中执行此操作: catalina版本
  2. 导航到CATALINA_HOME配置目录,该目录显示在上一条命令的输出中.

cd /usr/local/Cellar/tomcat/8.0.22/libexec/conf

  • 注意:在我的示例中,我使用自制软件安装了tomcat 8,用您的命令行输出中显示的内容替换了此路径.

  1. 验证 server.xml 是否包含 UserDatabase 资源(如果未添加):
  1. Verify that the server.xml contains a UserDatabase resource (if it doesn't add it):

  <GlobalNamingResources>
      <Resource name="UserDatabase" auth="Container"
          type="org.apache.catalina.UserDatabase"
          description="User database that can be updated and saved"
          factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources> 

默认情况下,tomcat使用内存数据库存储用户和角色.这是在conf/server.xml中配置的.并委派用户&conf/tomcat-users.xml文件中的角色声明.请参阅: http://tomcat.apache.org/tomcat-8.0-doc/realm-howto.html#UserDatabaseRealm 了解更多信息.

  1. 然后确认 config/user-tomcat.xml 存在并且看起来像这样:
  1. Then verify that config/user-tomcat.xml exists and looks like this:

  <tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd">
     <role rolename="admin"/>
     <role rolename="manager-script"/>
     <user username="admin" roles="admin,manager-script" password="admin" />
  </tomcat-users>

现在,您已经准备好发动战争!

Now, you're ready to deploy a war!

有两种方法可以做到这一点...

Here are two ways to do that...

使用wget:

wget 是一个漂亮的工具,可让您通过命令行执行http请求.我建议使用类似 homebrew 的包管理器进行安装,否则,您可以使用此

wget is a nifty tool that lets you do http requests via the command line. I recommend installing it using a package manager like homebrew, otherwise, you can install using this wget install guide.

  1. 首先重新启动服务器,以获取可能已进行的所有配置更改. catalina stop ,然后 catalina start ,将通过bash解决问题.
    *注意:使用wget开始向tomcat部署战争时,需要先启动tomcat.
  2. 现在执行以下命令:
  1. First restart your server to pick up any configuration changes that you may have done. catalina stop, then catalina start, will do the trick from bash.
    *Note: When using wget to start deploy a war to tomcat, tomcat needs to be started first.
  2. Now execute the following command:

wget --http-user=admin --http-password=admin  "http://localhost:8080/manager/text/deploy?war=file:/Users/yourusername/app/target/APP-1.0.0.war&path=/app"

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆