24 虚拟主机与Tomcat【Virtual Hosting and Tomcat】
来源:互联网 发布:关家垴战斗 知乎 编辑:程序博客网 时间:2024/05/29 16:41
Apache Tomcat 6.0
虚拟主机与Tomcat【Virtual Hosting and Tomcat】
目录【Table of Contents】背景【Assumptions】
- 背景【Assumptions】
- server.xml
- Web应用目录【Webapps Directory】
- 配置环境【Configuring Your Contexts】
- 综述【General】
- context.xml 配置方法#1 【context.xml - approach #1】
- context.xml 配置方法#2 【context.xml - approach #2】
- 进阶内容【Further Information】
server.xml作为全文的背景,假设你要将你开发的应用程序映射到名叫ren和stimpy的主机名上。还要假设,有一个正在运行的Tomcat服务,$CATALINA_HOME 是对于这个服务的安装路径的引用,例如:/usr/local/tomcat。
【For the sake of this how-to, assume you have a development host with two host names,ren
andstimpy
. Let's also assume one instance of Tomcat running, so$CATALINA_HOME
refers to wherever it's installed, perhaps/usr/local/tomcat
. 】
另外,文中会使用unix系统的路径分隔符和命令;如果你使用的是windows系统,请自行修改。
【Also, this how-to uses Unix-style path separators and commands; if you're on Windows modify accordingly. 】
Web应用目录【Webapps Directory】作为最简单的方法,就是去编辑server.xml文件的Enging元素,像下面这样:
【At the simplest, edit the Engine portion of yourserver.xml
file to look like this: 】<Engine name="Catalina" defaultHost="ren"> <Host name="ren" appBase="renapps"/> <Host name="stimpy" appBase="stimpyapps"/></Engine>注意,每个应用的appBase下的目录结构都可能不太一样。可以查看Engine和Host元素的属性的相关文档。
【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 Engine and Host elements. 】
配置环境【Configuring Your Contexts】为每一个虚拟主机创建如下的目录结构:
【Create directories for each of the virtual hosts: 】mkdir $CATALINA_HOME/renappsmkdir $CATALINA_HOME/stimpyapps
综述【General】context.xml配置方法1【context.xml - approach #1】Contexts元素通常位于appBase目录下。例如,将ren虚拟主机映射到foobar.war这个文件上,使用$CATALINA_HOME/renapps/foobar.war。虚拟主机ren的默认或者ROOT环境是$CATALINA_HOME/renapps/ROOT.war (WAR) 或者
$CATALINA_HOME/renapps/ROOT
(directory).
【Contexts are normally located underneath the appBase directory. For example, to deploy thefoobar
context as a war file in theren
host, use$CATALINA_HOME/renapps/foobar.war
. Note that the default or ROOT context forren
would be deployed as$CATALINA_HOME/renapps/ROOT.war
(WAR) or$CATALINA_HOME/renapps/ROOT
(directory). 】
注意:一个主机环境下的docBase与appBase是不同的。
【NOTE: The
docBase
for a context should never be the same as theappBase
for a host. 】context.xml配置方法1【context.xml - approach #2】在你的环境下,创建一个META-INF目录,将你的环境上下文定义写在这个目录下的context.xml文件中。例如$CATALINA_HOME/renapps/ROOT/META-INF/context.xml 这样使得你将应用打包成一个war文件时,部署是非常容易的。
【Within your Context, create aMETA-INF
directory and then place your Context definition in it in a file namedcontext.xml
. i.e.$CATALINA_HOME/renapps/ROOT/META-INF/context.xml
This makes deployment easier, particularly if you're distributing a WAR file. 】进阶内容【Further Information】在$CATALINA_HOME/conf/Catalina 下创建与你的虚拟主机一致的结构,例如:
【Create a structure under$CATALINA_HOME/conf/Catalina
corresponding to your virtual hosts, e.g.: 】mkdir $CATALINA_HOME/conf/Catalina/renmkdir $CATALINA_HOME/conf/Catalina/stimpy注意上面Catalina目录后面的目录名称,这个名字与Enging元素的name属性一致。
【Note that the ending directory name "Catalina" represents the
name
attribute of the Engine element as shown above. 】
现在对于你的默认应用,添加如下:
【Now, for your default webapps, add: 】
$CATALINA_HOME/conf/Catalina/ren/ROOT.xml$CATALINA_HOME/conf/Catalina/stimpy/ROOT.xml
如果你需要使用Tomcat manager管理所有主机的web应用,你需要再进行如下操作:
【If you want to use the Tomcat manager webapp for each host, you'll also need to add it here: 】
cd $CATALINA_HOME/conf/Catalinacp localhost/manager.xml ren/cp localhost/manager.xml stimpy/请查阅Context元素的其他属性的配置文档
【Consult the configuration documentation for other attributes of the Context element. 】
-------------------------------------------------------
终于在年前将Tomcat6新增的这几篇文档翻译完了,这些日子一直查看自己的博客,根本就没人看呀,呵呵,可见自己根本没有人气。要努力了。今天是大年二十九,上班的最后一天,明天放假准备过年,祝我新的一年取得理想的成绩。
- 24 虚拟主机与Tomcat【Virtual Hosting and Tomcat】
- 虚拟主机(virtual hosting)
- ubantu linux Virtual Hosting(虚拟主机)
- Tomcat虚拟主机与原理
- Tomcat虚拟主机与虚拟目录
- tomcat virtual folder and virtual host
- tomcat 虚拟主机
- [虚拟主机]Tomcat
- Tomcat 虚拟主机
- tomcat 虚拟主机
- tomcat 虚拟主机
- Tomcat虚拟主机
- tomcat中Virtual Host(虚拟主机)的设置
- tomcat中Virtual Host(虚拟主机)的设置
- tomcat中Virtual Host(虚拟主机)的设置
- Tomcat配置虚拟主机(No.24)
- 关于Tomcat虚拟主机域名的设置--配置虚拟主机(Virtual Hosts)
- Tomcat虚拟目录与虚拟主机的配置
- C# WinForm 实现增删改查等功能(Access版) 系列之四-删除
- zoj 2952 Find All M^N Please
- 基于角色的权限设计
- POJ 1411 数论+优化
- C# WinForm 实现增删改查等功能(Access版) 系列之八-导出数据到Excel
- 24 虚拟主机与Tomcat【Virtual Hosting and Tomcat】
- C# WinForm 实现增删改查等功能(Access版) 系列之七-图片处理
- 27 在Maven中使用【Mavenized】
- C# WinForm 实现增删改查等功能(Access版) 系列之六-分页
- TOJ 比赛C题 Visiting Cows (TJU 2011 Exercise Contest 04)
- C# WinForm 实现增删改查等功能(Access版) 系列之五-查询
- 【Android入门】注册监听器的几种方式
- 在C#中使用控件DataGridView实现数据库增删改查
- 科幻小说《三体》中的几个问题。。