如何部署的Eclipse的Java Web动态的项目在Amazon EC2上?项目、动态、Java、Eclipse

2023-09-11 08:43:01 作者:人花亦醉そ

我想创建一个Web项目,能够与Amazon RDS进行通信。我知道如何使本地主机项目连接到使用JDBC一个RDS。

I'm trying to create a web project that is able to communicate with Amazon RDS. I know how to make a localhost project connect to a RDS with JDBC.

然而,问题是,我从来没有试图部署我的项目(​​因此,例如有人可以键入 somePage.com ,并进入我的网页)。

However, the problem is that I never tried to deploy my project (so that, for example someone can type somePage.com, and go to my webpage).

我有一个 Amazon EC2实例,我已经写了一个简单的Hello World JSP页面。我能够编译并运行在的Eclipse的Web动态项目使用已安装的 Apache Tomcat服务器,然后键入本地主机:8080 / SomePage的然后我可以看到我的Hello World雨后春笋般冒出来。

I have an Amazon EC2 instance, and I've already written a simple hello world jsp page. I am able to compile it and run the Eclipse Web Dynamic Project using the installed Apache Tomcat Server, and then typing localhost:8080/somePage then I can see my hello world popping up.

不过,我怎么部署我对这个EC2实例项目?我使用Windows Server 2012的版本。

However, how do I deploy my project on this EC2 instance? I'm using Windows Server 2012 edition.

我的整个想法是,一​​旦我有一个AMI图像的所有设置,那么我可以只使用自动量程扩展我的网页与AMI图像。

My whole idea is that once I have one AMI image all setup, then I can just use autoscale to scale my webpage with that AMI image.

任何人都可以点我朝着正确的方向?

Can anyone point me to the right direction?

推荐答案

按照下面的步骤:

安装的Apache Tomcat上您的Amazon EC2实例。 通常你需要做的就是下载最新版本,解压缩,然后通过运行启动的apache-tomcat的文件夹\ BIN \的startup.bat 。 (您也可以donwload一个安装程序,并将它设置为Windows服务。请此链接了解更多详情)。 确保在继续(在浏览器中打开它的地址,之前测试它像 http://yourinstaceaddress.com :8080 / ) Setup Apache Tomcat on your Amazon EC2 instance. Usually all you have to do is download the current version, unzip it, and start it by running apache-tomcat-folder\bin\startup.bat. (You can also donwload an installer and set it up as windows service. Check this link for more details). Make sure you test it before continuing (open its address on a browser, something like http://yourinstaceaddress.com:8080/). 在Eclipse中,右键单击Web项目并选择导出。然后选择在导出窗口WAR文件,然后选择下一步。选择项目,导出的.war 文件名和文件夹。更详细的解释可以发现here和这里(含图片)。 In Eclipse, right click on a Web project and select Export. Then select WAR file in the Export window and then select Next. Choose the project, the .war file name and folder to export. More detailed explanation can be found here and here (with pictures). 的,到目前为止,最简单的做到这一点的方法就是把你的的.war (比如 myapp.war )文件中的的apache-tomcat的文件夹\ webapps中\ 文件夹。 还有其他的方法,比如通过Tomcat经理。但是,他们可能会非常棘手,作为一个新的用户,你应该避免他们。 (不要担心:简单的方法是确定生产部署)。 The, by far, simplest way to do this is to place your .war (say myapp.war) file in your apache-tomcat-folder\webapps\ folder. There are other ways, like via Tomcat Manager. But they can be tricky and, as a new user, you should avoid them. (Don't worry: the simple method is ok for production deployment). 访问的网址:说你的的.war 的名字叫 myapp.war 。你应该访问 http://yourinstaceaddress.com:8080/myapp Visit the url: say your .war's name was myapp.war. You should visit http://yourinstaceaddress.com:8080/myapp

就是这样。如果你曾经编辑应用程序,重复步骤2-4(但删除了执行步骤3之前创建的的webapps \ MyApp的\ 文件夹)。

That's it. If you ever edit the app, repeat steps 2-4 (but delete the webapps\myapp\ folder created before executing step 3).