Tomcat 7 中的虚拟主机
我正在尝试在 Tomcat 7.0.20 中拥有虚拟主机
而不重命名所有内容 ROOT AND 前面没有使用 Apache http 服务器
到目前为止完成的步骤
将假域名放入 Windows 主机文件中 127.0.0.1 fakedomain.com
启动 Tomcat 并登录到主机管理器。 添加虚拟主机。 名称 : fakedomain.com 别名:www.fakedomain.com 应用程序基础:fakedomain 所有设置均为“是”
此时,tomcat 将创建 app 目录和 conf 目录,并为假域设置管理器应用程序。
我将 WAR 文件“Animotest-1.war”复制到 fakedomain 应用程序目录。我现在可以使用 http://fakedomain.com/Animotest-1/ 访问我的应用程序。小胜利:)
现在我尝试将其设置为我的默认应用程序
我的理解是我需要将 ROOT.xml 文件放入 conf/Catalina/fakedomain.com 目录中,其中包含以下内容的一些变体。
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="C:\Java\apache-tomcat-7.0.20\fakedomain\Animotest-1">
</Context>
结果是,tomcat 现在向我显示 Tomcat 附带的 ROOT 页面,而不是我的虚拟主机应用程序,并且我的应用程序现在是 404。
有任何线索吗?
I'm trying to have virtual hosts in Tomcat 7.0.20
WITHOUT rename everything ROOT AND
WITHOUT using Apache http server in front
Steps done so far
put fake domain in windows host file
127.0.0.1 fakedomain.com
Started Tomcat and logged into Host Manager.
Add virtual host.
Name : fakedomain.com
Aliasas : www.fakedomain.com
App base: fakedomain
Yes to all settings
At this point tomcat creates the app directory and conf directory and setups the manager app for the fake domain.
I copy a WAR file 'Animotest-1.war' to the fakedomain app directory. I can now access my app using http://fakedomain.com/Animotest-1/. Small victory :)
Now I'm trying to set it as my default app
My understanding is that I need to put a ROOT.xml file in the conf/Catalina/fakedomain.com directory with some variation of the following content.
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="C:\Java\apache-tomcat-7.0.20\fakedomain\Animotest-1">
</Context>
The resulting behavior is that tomcat now shows me the ROOT page that comes with with Tomcat not my virtual host app and my app is now 404.
Any clues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不知道为什么你想要以困难的方式做事,但就这样吧。
您需要将 Animotest-1.war 放置在 appBase 目录之外的位置,以便 Tomcat 无法通过自动部署找到它。将完整路径放入 docBase 属性中(正如您所做的那样 - 只需位于 Tomcat 目录结构之外的位置)。确保appBase下没有ROOT目录或ROOT.war文件,并删除Tomcat的工作目录以确保其中没有以前部署留下的任何令人困惑的内容。
Not sure why you want to do things the hard way, but so be it.
You need to place the Animotest-1.war in a location outside of the appBase directory so that Tomcat won't find it via auto-deployment. Put the full path in the docBase attribute (as you have done - just needs to be in a location outside of Tomcat's directory structure). Make sure there is no ROOT directory or ROOT.war file under the appBase, and erase Tomcat's work directory to make sure there's nothing confusing in there left over from previous deployments.
在 Tomcat 的自定义主机上部署应用程序
为我工作,没有 Windows 主机需要修改文件。我认为对我来说关键是将 appbase 放在 root.xml 和 server.xml 中。必须从 server.xml 中删除它,一切都是肉汁。
Deploy application on custom host of Tomcat
Worked for me, no windows host file modification necessary. I think the key for me was having the appbase in the root.xml and in the server.xml. Had to remove it from server.xml and everything was gravy.