单个Apache Tomcat上的多个域 [英] Multiple domains on single apache tomcat

查看:149
本文介绍了单个Apache Tomcat上的多个域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个域,但是只有一个运行tomcat 7的虚拟服务器.我有自己的ubuntu Linux,在虚拟服务器上运行具有完全根访问权限.我设置了Shorewall防火墙,该防火墙将端口80上的任何请求转发到端口8080(tomcat正在侦听的端口).

I have two domains but only one virtual server which runs a tomcat 7. I have my own ubuntu Linux with full root access running on the virtual server. I setup shorewall firewall which forwards any request on port 80 to port 8080 (where tomcat is listening on).

所以我已经在网上搜索了,但是我只找到在我的情况下不起作用的解决方案".这是我到目前为止所做的:

So I already searched the net but I only find "solution" that do not work in my case. This is what I did so far:

  1. 我将我的websiteA.war作为ROOT.war复制到$ CATALINA_HOME/webapps/文件夹中
  2. 我还将我的websiteB.war作为WebsiteB.war复制到$ CATALINA_HOME/webapps/文件夹中
  3. 我以以下方式修改了$ CATALINA_HOME/conf/server.xml:

  1. I copied my websiteA.war as ROOT.war into the $CATALINA_HOME/webapps/ folder
  2. I also copied my websiteB.war as WebsiteB.war into the $CATALINA_HOME/webapps/ folder
  3. I modified my $CATALINA_HOME/conf/server.xml in the following way:

主机名="www.websiteA.com" appBase ="webapps" unpackWARs ="true" autoDeploy ="true"

Host name="www.websiteA.com" appBase="webapps" unpackWARs="true" autoDeploy="true"

主机名="www.websiteB.de" appBase ="webapps/websiteB" unpackWARs ="true" autoDeploy ="true"

Host name="www.websiteB.de" appBase="webapps/websiteB" unpackWARs="true" autoDeploy="true"

主机名="localhost" appBase ="webapps" unpackWARs ="true" autoDeploy ="true"

Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"

我在"$ CATALINA_HOME/conf/Catalina/www.websiteB.com"文件夹中创建了以下文件ROOT.xml:

I created the following file ROOT.xml in the folder "$CATALINA_HOME/conf/Catalina/www.websiteB.com" :

?xml版本="1.0"编码="UTF-8"?

?xml version="1.0" encoding="UTF-8"?

上下文displayName ="www.websiteB.com" docBase =" path ="

Context displayName="www.websiteB.com" docBase="" path=""

/上下文

重新启动tomcat. websiteA.com部署在"/"下,websiteB.com部署在"/websiteB"下

Restarted tomcat. The websiteA.com gets deployed under "/" and websiteB.com gets deployed unter "/websiteB"

我在做什么错了?

推荐答案

转到您的$CATALINA_HOME/conf/server.xml文件.

在那里,您将找到以下部分:

There, you will find the following section:

<Engine name="Catalina" defaultHost="localhost">
    <!-- ... some other stuff ... -->
    <Host name="www.websiteA-Address" appBase="webapps" unpackWARs="true" autoDeploy="true"></Host>
    <Host name="www.websiteB-Address" appBase="directory/of/WAR-files-for-B" unpackWARs="true" autoDeploy="true"></Host>
    <Host name="websiteB-Address" appBase="directory/of/WAR-files-for-B" unpackWARs="true" autoDeploy="true"></Host>
    <Host name="www.websiteC-Address"  appBase="directory/of/WAR-files-for-C" unpackWARs="true" autoDeploy="true"></Host>
</Engine>

因此,appBase将是您必须放置ROOT.war(!)的目录,而name是将映射到该目录的域名.

So, appBase will be the directory where your will have to put your ROOT.war(!) and name is the domain name that will be mapped onto this directory.

directory/of/WAR-files$CATALINA_HOME中的子目录,与标准文件夹webapps相同,具有(!!!).因此,这两个目录共存!

directory/of/WAR-files is a subdirectory in $CATALINA_HOME, that is the same level(!!!) as the standard folder webapps. So both directories coexist!

这篇关于单个Apache Tomcat上的多个域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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