如何在没有web应用程序的情况下设置tomcat虚拟主机? [英] How to setup a tomcat virtualhost without webapps?

查看:107
本文介绍了如何在没有web应用程序的情况下设置tomcat虚拟主机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Webapp从resin迁移到Tomcat7.让我感到困惑的是,我不知道如何为一个虚拟主机设置一个默认" webapp?

I am trying to migrate my webapp from resin to Tomcat7 . One thing confuses me is I don't know how to setup a 'default' webapp for one virtual host ?

也就是说,我的站点只有一个应用程序:"/",位于"/home/destiny/www"中.里面有很多PHP脚本(由apache服务),里面有一个WEB-INF目录,带有一个标准的JavaEE应用程序. My app is not packaged in WAR , it is default expanded.

That is , my site has just one app : "/" , located in "/home/destiny/www" . There are many PHP scripts inside (served by apache) , and one WEB-INF directory inside , with a standard JavaEE app. My app is not packaged in WAR , it is default expanded.

我试图找到有关如何在tomcat 7中设置虚拟主机的文档,但是所有示例都需要一个"webapps"目录来扩展WAR,但这不是我的情况!

I try to find documents about how to setup a virtual host in tomcat 7 , but all examples need a 'webapps' directory for WARs to expand , but that's not my case !

这是我的server.xml设置(tomcat 7.0.23):

Here is my server.xml settings (tomcat 7.0.23 ) :

<Host name="myhost.com" xmlBase="/home/destiny/www" 
  unpackWARS="false" autoDeploy="true">
  <Context path="/" docBase="." />
</Host>

<!-- default tomcat's host -->
<Host name="localhost"  appBase="webapps"
  unpackWARs="true" autoDeploy="true"> ... </Host>

当我启动tomcat时,我看到我的webapp没有加载,只有tomcat的webapp(host-manager,manager,examples,docs,ROOT ...)被加载.当我打开网站时,它会显示tomcat的默认屏幕(带有损坏的图像).

When I start tomcat , I see my webapp not loaded , only tomcat's webapps (host-manager , manager , examples , docs , ROOT ...) loaded. When I open my site , it shows tomcat's default screen (with broken images).

配置不起作用...(我尝试了xmlBase,appBase,docBase ...,但是全部都无效了)

The configuration is not working... ( I tried xmlBase , appBase , docBase ... but all in invain)

似乎一个解决方案是在/home/destiny/www/webapps/ROOT目录中名为'ROOT'的Web应用程序,但是我不想要该解决方案!我想要默认的Web应用程序在/home/destiny/www中.并且不会安装任何其他Web应用程序(我不需要webapps dir).

It seems one solution is a webapp named 'ROOT' in /home/destiny/www/webapps/ROOT directory , but I don't want that solution ! I want my default web app in /home/destiny/www . and there'll be no other webapps installed (I don't need a webapps dir ).

如何解决(在树脂中很容易实现)?谢谢.

How to solve it (It's so easy to achieve in resin) ? Thanks.

推荐答案

要指向您自己的目录,请尝试以下操作:

To point to your own directory try the following:

转到tomcat文件夹%path_to_tomcat%/conf/Catalina/localhost 您还可以根据需要将localhost更改为主机,但是如果您唯一要做的是将应用程序放在'/'上,那么localhost就可以了.

go to the tomcat folder %path_to_tomcat%/conf/Catalina/localhost You can also change localhost to your host if you want, but if the only thing you are trying to do is get your app on '/' then localhost is fine.

在先前定义的文件夹中创建一个名为ROOT.xml的文件.在该文件中添加以下内容

create a file called ROOT.xml in the previously defined folder. In that file add the following

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/home/destiny/www">
</Context>

也可以查看%path_to_tomcat%/webapps/,如果您不希望使用默认的tomcat页面,请删除/移动/重命名其中的ROOT文件夹.

Also look in %path_to_tomcat%/webapps/, and delete/move/rename the ROOT folder that is there if you don't want the default tomcat page to be there.

请参见方法2 @ 此链接有关更多详细信息.

See the approach #2 @ this link for more details.

这篇关于如何在没有web应用程序的情况下设置tomcat虚拟主机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆