Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2517782
  • 博文数量: 540
  • 博客积分: 11289
  • 博客等级: 上将
  • 技术积分: 6160
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-11 20:27
个人简介

潜龙勿用,见龙在田

文章分类

全部博文(540)

文章存档

2018年(2)

2013年(5)

2012年(24)

2011年(104)

2010年(60)

2009年(217)

2008年(128)

分类:

2008-09-26 14:13:01

Virtual Hosting and Tomcat


For the sake of this how-to, assume you have a development host with two host names, ren and stimpy. Let's also assume one instance of Tomcat running, so $CATALINA_HOME refers to wherever it's installed, perhaps /usr/local/tomcat.

Also, this how-to uses Unix-style path separators and commands; if you're on Windows modify accordingly.

At the simplest, edit the portion of your server.xml file to look like this:





Note that the directory structures under the appBase for each host should not overlap each other.

Consult the configuration documentation for other attributes of the and elements.

Create directories for each of the virtual hosts:

mkdir $CATALINA_HOME/renapps
mkdir $CATALINA_HOME/stimpyapps

Contexts are normally located underneath the appBase directory. For example, to deploy the foobar context as a war file in the ren host, use $CATALINA_HOME/renapps/foobar.war. Note that the default or ROOT context for ren would be deployed as $CATALINA_HOME/renapps/ROOT.war (WAR) or $CATALINA_HOME/renapps/ROOR (directory).

NOTE: The docBase for a context should never be the same as the appBase for a host.

Within your Context, create a META-INF directory and then place your Context definition in it in a file named context.xml. i.e. $CATALINA_HOME/renapps/ROOT/META-INF/context.xml This makes deployment easier, particularly if you're distributing a WAR file.

Create a structure under $CATALINA_HOME/conf/Catalina corresponding to your virtual hosts, e.g.:

mkdir $CATALINA_HOME/conf/Catalina/ren
mkdir $CATALINA_HOME/conf/Catalina/stimpy

Note that the ending directory name "Catalina" represents the name attribute of the element as shown above.

Now, for your default webapps, add:

$CATALINA_HOME/conf/Catalina/ren/ROOT.xml
$CATALINA_HOME/conf/Catalina/stimpy/ROOT.xml

If you want to use the Tomcat manager webapp for each host, you'll also need to add it here:

cd $CATALINA_HOME/conf/Catalina
cp localhost/manager.xml ren/
cp localhost/manager.xml stimpy/

Consult the configuration documentation for other attributes of the element.


阅读(1393) | 评论(0) | 转发(0) |
0

上一篇:Tomcat配置多域名

下一篇:date命令集锦

给主人留下些什么吧!~~