如何在tomcat上部署Java Web应用程序(.war)?

如何在tomcat上部署Java Web应用程序(.war)?

问题描述:

我有一个Java Web应用程序的 .war 文件。现在我想将它上传到我的ftp服务器,以便我可以执行它。

I have a .war file of a Java Web Application. Now I want to upload it to my ftp server so that I can execute it.

我应该执行哪些步骤来运行它?

What steps I should perform to run it?

webapp的上下文路径是/ mywebapp

The context path of the webapp is /mywebapp

编辑

实际上,我的ftp服务器名称为 ftp://bilgin.ath.cx/ 并且我已上传我的 TestWebApp.war 文件到这个目录: ftp://bilgin.ath.cx/web

Actually, my ftp server name is ftp://bilgin.ath.cx/ and I have uploaded my TestWebApp.war file to this dir: ftp://bilgin.ath.cx/web

那么访问网络应用程序 index.html 页面的URL应该是什么

Then what should be the URL to access the index.html page of the webapplication

Tomcat 正在监听 8082

Apache使用jk连接器访问Tomcat。

Apache access Tomcat with jk connector.

正如其他人所指出的,部署WAR最直接的方法是将其复制到Tomcat安装的 webapps 。另一种选择是使用管理器应用程序如果安装它(情况并非总是如此),如果它已正确配置(即,如果您有用户的凭据)分配到适当的组)如果它可以通过Internet等不安全的网络访问它(但这不太可能,你没有提到任何VPN访问)。因此,这将为您提供 webapp 目录。

As others pointed out, the most straightforward way to deploy a WAR is to copy it to the webapps of the Tomcat install. Another option would be to use the manager application if it is installed (this is not always the case), if it's properly configured (i.e. if you have the credentials of a user assigned to the appropriate group) and if it you can access it over an insecure network like Internet (but this is very unlikely and you didn't mention any VPN access). So this leaves you with the webappdirectory.

现在,如果已安装Tomcat并在 bilgin.ath.cx (因为这是你上传文件的机器),我注意到Apache正在侦听端口 80 on那个机器人所以我敢打赌,Tomcat没有直接暴露,而且请求必须经过Apache。在这种情况下,我认为部署新的webapp并使其对Internet可见将涉及编辑Apache配置文件( mod_jk ?, mod_proxy ?)。您应该向我们提供更多详细信息或与您的托管服务提供商讨论。

Now, if Tomcat is installed and running on bilgin.ath.cx (as this is the machine where you uploaded the files), I noticed that Apache is listening to port 80 on that machien so I would bet that Tomcat is not directly exposed and that requests have to go through Apache. In that case, I think that deploying a new webapp and making it visible to the Internet will involve the edit of Apache configuration files (mod_jk?, mod_proxy?). You should either give us more details or discuss this with your hosting provider.

更新:正如所料, bilgin .ath.cx 正在使用Apache Tomcat + Apache HTTPD + mod_jk的。配置通常涉及两个文件:用于配置工作程序的 worker.properties 文件和用于Apache的 httpd.conf 。现在,在没有看到当前配置的情况下,给出明确的答案并不容易,但基本上,您可能需要在Apache httpd中添加 JkMount 指令.conf 用于新的webapp 1 。请参阅 mod_jk 文档,它有一个简单的配置示例。请注意,修改 httpd.conf 将需要访问(显然)和适当的权限,并且您必须在修改后重新启动Apache。

Update: As expected, the bilgin.ath.cx is using Apache Tomcat + Apache HTTPD + mod_jk. The configuration usually involves two files: the worker.properties file to configure the workers and the httpd.conf for Apache. Now, without seeing the current configuration, it's not easy to give a definitive answer but, basically, you may have to add a JkMount directive in Apache httpd.conf for your new webapp1. Refer to the mod_jk documentation, it has a simple configuration example. Note that modifying httpd.conf will require access to (obviously) and proper rights and that you'll have to restart Apache after the modifications.

1 如果你要部署到已经使用过的Tomcat实例,我认为你不需要定义一个新的worker,特别是如果这听起来像中文的话你:))

1 I don't think you'll need to define a new worker if you are deploying to an already used Tomcat instance, especially if this sounds like Chinese for you :)