在 Tomcat 的自定义主机上部署应用程序 [英] Deploy application on custom host of Tomcat
问题描述
我在部署应用程序时遇到了一些问题.
I got some issues to deploy my application.
环境:Ubuntu 10.04、Tomcat 7.02(从 tomcat 站点的存档安装,而不是从存储库),服务器手动运行和停止,不使用任何 IDE.
Environment: Ubuntu 10.04, Tomcat 7.02 (Install from archive from tomcat site, not from repositories), server is run and stoped manualy, not using any IDE.
对于我在 $CATALINA_HOME/conf/server.xml
中创建的第一个主机:
For the first I've created host in $CATALINA_HOME/conf/server.xml
:
<Host name="java.dev"
appBase="/home/krasilich/java/"
autoDeploy="true" >
<Alias>www.java.dev</Alias>
</Host>
然后在$CATALINA_HOME/conf/Catalina/java.dev/siloc.xml
中创建一个上下文:
Then create a context in $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml
:
<Context docBase="siloc/web/" />
并得到错误
宿主 appBase 内的 docBase/home/krasilich/java/siloc/web/已指定,将被忽略
A docBase /home/krasilich/java/siloc/web/ inside the host appBase has been specified, and will be ignored
但是,如果我将 manager.xml 复制到 $CATALINA_HOME/conf/Catalina/java.dev/
我可以运行管理器应用程序.如果我通过管理器部署我的应用程序 - 它说一切顺利,但我仍然在 java.dev:8080/siloc/上看到 404:8080/siloc/
But, if I copy manager.xml to $CATALINA_HOME/conf/Catalina/java.dev/
I can run manager app.
If I deploy my application through manager - it says that everything is going well, but I still see the 404 on java.dev:8080/siloc/
这就是自定义主机的全部内容.
That's all about custom host.
我也尝试通过 localhost 上的管理器部署应用程序并且它有效,我可以在 localhost:8080/siloc/上看到我的Hello Word"
I've tried to deploy application through manager on localhost also and it works, I can see my "Hello Word" on localhost:8080/siloc/
但是,如果我更改 index.jsp 中的文本,它不会影响前端.重新部署"按钮对我没有帮助.
But, if I change the text in my index.jsp it'll not affected on frontend. The "Redeploy" button isn't help for me.
正如我提到的 manager 只是将应用程序文件复制到 webapps 目录,不要对配置文件进行任何更改.
As I mentioned manager just copy application files to webapps directory, and don't make any changes in config files.
我只需要在我的文件系统中的任何目录中部署应用程序(实际上它将是 /home/krasilich/java/
).
All I need that I can deploy application in any directory in my filesystem (actually it will be /home/krasilich/java/
).
如果我可以在像 java.dev 这样的自定义主机上执行此操作,那就太好了我需要答案,为什么 $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml
中的上下文对我不起作用,我该怎么做才能使其保持一致?
And it would be great if I can do this on custom host like java.dev
I need the answer, why the context in $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml
isn't working for me, and what shall I do to make it consistent?
谢谢.
推荐答案
我已经能够重现您的问题.
I have been able to replicate your problem.
在修改了 appBase
和 docBase
的组合后,我可以建议两种解决方法.看起来两者不一起操作.
There are 2 workaround I can suggest after tinkering around with combinations of appBase
and docBase
. Looks like the two do not operate together.
从 server.xml
中删除 appBase
并在 $CATALINA_HOME/的
docBase
中指定 Web 应用程序的完整路径conf/Catalina/java.dev/siloc.xml
Remove the appBase
from server.xml
and specify the full path to the web app in docBase
in the $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml
我假设您的值将是 /home/krasilich/java/siloc/web/siloc
.
注意:仅指定到父文件夹/home/krasilich/java/siloc/web/
将显示父文件夹的目录列表
Note: specifying only up to the parent folder /home/krasilich/java/siloc/web/
will show you a directory listing of the parent folder
在$CATALINA_HOME/conf/Catalina/java.dev/siloc.xml
删除docBase
,只保留
Tomcat 从 $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml
推断 webapp 名称 siloc
并查找名为 siloc 的 webapp
在 appBase 中.
Tomcat infers the webapp name siloc
from the $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml
and it looks for the webapp named siloc
in the appBase.
这允许 java.dev:8080/siloc/工作,前提是您还将 server.xml
中的 appBase
更改为 webapp siloc 的父文件夹代码>.
This allows java.dev:8080/siloc/ to work provided you also change the appBase
in server.xml
to the parent folder of your webapp siloc
.
为了回应 manager
工作的原因,同样的原因 - manager.xml 中没有 docBase
In response to why manager
works, same reason - there is no docBase in the manager.xml
我正在尝试 docBase 的其他组合,但我给出的任何值都会引发
I am trying other combinations of docBase but any value I give throws the
警告:已指定宿主 appBase 内的 docBase ...,将被忽略
WARNING: A docBase ... inside the host appBase has been specified, and will be ignored
所以我的结论是删除docBase.这不是一个好主意 - 因为父文件夹的完整路径随后被硬编码在 server.xml 中.
So my conclusion is to remove the docBase. This is not a good idea - since the full path to parent folder is then hardcoded in server.xml.
这篇关于在 Tomcat 的自定义主机上部署应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!