如何在 Linux 机器上部署 WAR 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6530401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 04:50:18  来源:igfitidea点击:

How to deploy a WAR file on Linux machine

linuxapache

提问by

I have a Linux Machine. Apache server is running and I need to deploy my project which is a .war file developed on Windows machine.

我有一台 Linux 机器。Apache 服务器正在运行,我需要部署我的项目,该项目是在 Windows 机器上开发的 .war 文件。

Can someone give me bit idea how to do that?

有人可以给我一点想法如何做到这一点吗?

采纳答案by Rupok

if you have FTP or SCP access to the directories where Tomcat is installed, you should be able to simply copy the generated WAR file to the tomcat/webapps directory. Tomcat will automatically deploy the war for you.

如果您对安装 Tomcat 的目录具有 FTP 或 SCP 访问权限,您应该能够简单地将生成的 WAR 文件复制到 tomcat/webapps 目录。Tomcat 会自动为你部署战争。

When redeploying, I find it safest to delete the original .WAR file in Tomcat, and tomcat will automatically destory the exploded directory for you. When that's done, copy up the .WAR file.

重新部署的时候,我觉得删除Tomcat中原有的.WAR文件最安全,tomcat会自动为你销毁解压后的目录。完成后,复制 .WAR 文件。

Finally, make sure you copy the .WAR file "all at once". If you have a slow upload, Tomcat will try and deploy the .WAR file even though it has not completely been uploaded yet. This will lead to a partial or unsuccessful deployment. It's best if you upload to a neutral directory (home directory, temp, whichever), and then either rename (using mv) the .WAR into tomcat, or simply copy it there using the local file systems copy command. Much faster than the upload. Safest way is to mv the file from the same filesystem.

最后,确保“一次性”复制 .WAR 文件。如果上传速度较慢,Tomcat 会尝试部署 .WAR 文件,即使它尚未完全上传。这将导致部分部署或不成功部署。最好是上传到一个中性目录(主目录、临时目录),然后将 .WAR 重命名(使用 mv)到 tomcat,或者使用本地文件系统复制命令将其复制到那里。比上传快多了。最安全的方法是从同一文件系统 mv 文件。

All of this assumes you do not have any of the manager or admin ports open for Tomcat, as it provides mechanisms to remotely deploy applications directly.

所有这些都假设您没有为 Tomcat 打开任何管理器或管理端口,因为它提供了直接远程部署应用程序的机制。

But, in truth, simply removing the old app and slipping in the new app works simply and well for many applications.

但是,事实上,对于许多应用程序来说,简单地删除旧应用程序并插入新应用程序既简单又有效。