如何使用共享 Tomcat?
抱歉,我尝试搜索这个主题,但没有找到与我的问题相关的内容。 最近,我为其购买了域名和虚拟主机。我买它是为了将它用于我的 Java 项目。 我在主机上有 Tomcat 作为服务器。
我的问题是:如何使用托管 Tomcat,在我看来,它与 localhost(您可以无限制访问)有很大不同?
例如,如果我创建一个如下所示的 Spring 项目:
项目名称
<块引用>源代码
<块引用>
战争index.jsp
<块引用>
WEB-INFweb.xml
index.jsp 输出一个简单的 This is a test
web.xml
<欢迎文件列表>
<欢迎文件>
index.jsp
我创建了一个 Ant build.xml 来构建项目,但是当我从 http://domain.com/project-name
访问它时不起作用,我只能从 http://domain.com/project-name/war
访问该文件
如果我在本地主机上完成此操作,我会将其部署在 tomcat-path/ 中webapps,但是它如何在线运行呢?
Sorry, but I tried searching for this subject, but I didn't find related to my problem.
Recently, I bought a domain and web hosting for it. I bought it especially for using it for my Java projects.
I have Tomcat available as server on the hosting.
My question is: how do I work with a hosted Tomcat, which, in my opinion, it is quite different from localhost (where you could have unlimited access)?
For example, if I create a Spring project that looks like this:
project-name
src
warindex.jsp
WEB-INFweb.xml
The index.jsp outputs a simple This is a test
web.xml
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
I created an Ant build.xml that will build the project, but when I access from http://domain.com/project-name
it will not work, and I only cand access the file from http://domain.com/project-name/war
If I had done this on localhost, I'd deploy it in tomcat-path/webapps, but how does this work online?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是安装 Tomcat Manager Webapp,以便在使用 Tomcat 作为服务器的共享主机上部署应用程序。
编辑:
如果主机不为您提供 Tomcat Manager(就像我的情况一样),您仍然可以通过要求主机管理员配置您的 jk_mod 文件来部署您的 war 文件来完成任务。
追加这些行
但请注意,如果您的 Tomcat 版本是由 cPanel 的 EasyApache 提供的,您也必须处理一些问题 - 最新安装的 Tomcat 将是 5.5.33 (有点旧,对吧?),但您可以再次尝试调整旧版本并安装,假设6.xx
关于本次升级的教程:
这对我理解解决这个问题所涉及的概念有很大帮助:
另外要补充的是:在您的计算机上安装本地版本的Tomcat,首先将其部署在本地主机上。如果它可以工作,它也应该可以在线工作。
那些在 Tomcat 5.5.33 上使用 Spring Roo 的人,如果您已经知道,您无法部署您的项目,因为 Tomcat 太旧了,所以你必须立即升级你的Tomcat。
我希望这能帮助所有像我一样有困难的人。
The solution is to install Tomcat Manager Webapp in order to deploy applications on a shared hosting that uses Tomcat as server.
EDIT:
If the hosting doesn't offer you Tomcat Manager (as was in my case), you can still make it through by asking the administrator of your hosting to configure your jk_mod file to deploy your war files.
Append these lines
But be aware, if your version of Tomcat is brought to you by cPanel's EasyApache, you will have to deal with some issues there too - the latest installed Tomcat will be 5.5.33 (a bit old, right?), but again you can try tweaking the old version and install, let's say 6.x.x
A tutorial about this upgrade:
The thing that help me a lot to understand the concepts that were envolved in solving this problem:
An another thing to add: Install a local version of Tomcat on your machine, first deploy it on localhost. If there it works, it should be working online as well.
Those of you who work with Spring Roo, on Tomcat 5.5.33, if you already know, you cannot deploy your projects, becase of the too old Tomcat, so you have to upgrade your Tomcat immediately.
I hope this will help all of those who had difficulties like myself.