一直使用tomcat5,今天换用了tomcat6,没想到,tomcat6的虚拟主机配置,与tomcat5的有很多不同.
在tomcat5下,经过配置,我一直使用http://localhost/来进行日常的开发调试工作.
换了tomcat6,想当然的在context.xml的host标签中加入context标记,没想到,
Tomcat6不认了,于是乎,去官方看文档,在官方有文档中,有这样的描述 :
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).
意思也就是说,如果要配置成直接使用http://localhost/的方式进行访问,
要将war包命名为ROOT,同时根据文档:
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.
这样也就是说,在WEB-INF/META-INF下面,需要添加一个context.xml文件,这样做的主要目的一方面,是希望单独web应用的修改,不用重启tomcat服务器,就可以将新配置的修改 重新加载,另一方面,当然是希望各个应用的配置可以相互,隔离.
整个tomcat配置虚拟主机的官方文档在这里可以找到.
http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
经过反复尝试,最终得如下步骤:
1:修改/tomcat6/conf/server.xml
主要修改为:
<Engine name="Catalina" defaultHost="localhost">
这里的defaultHost 要与下面的 hostname 保持一致
name要与接下来创建的目录名一致
<Host name="localhost" appBase="F:"WebDeploy"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
其中,appBase指定了虚拟目录所在位置.
2.在/tomcat6/conf/下创建与"Engine"标签name属于指定值一致的目录名
比如我使用的是Catalina,那么就创建名为Catalina的目录,其下创建名为localhost(与Host标签的name属性一致)的目录 .
3.在我们的应用下,在目录META-INF添加ROOT.xml,内容为:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="" docBase="ROOT" debug="0" reloadable="true"></Context>
整个配置完成,重启服务器.
tomcat官方对Engine标签的说明:
AttributeDescription
backgroundProcessorDelay |
This value represents the delay in seconds between the invocation of the backgroundProcess method on this engine and its child containers, including all hosts and contexts. Child containers will not be invoked if their delay value is not negative (which would mean they are using their own processing thread). Setting this to a positive value will cause a thread to be spawn. After waiting the specified amount of time, the thread will invoke the backgroundProcess method on this engine and all its child containers. If not specified, the default value for this attribute is 10, which represent a 10 seconds delay.
|
className |
Java class name of the implementation to use. This class must implement the org.apache.catalina.Engine interface. If not specified, the standard value (defined below) will be used.
|
defaultHost |
The default host name, which identifies the Host that will process requests directed to host names on this server, but which are not configured in this configuration file. This name MUST match the name attributes of one of the Host elements nested immediately inside.
|
jvmRoute |
Identifier which must be used in load balancing scenarios to enable session affinity. The identifier, which must be unique across all Tomcat 6 servers which participate in the cluster, will be appended to the generated session identifier, therefore allowing the front end proxy to always forward a particular session to the same Tomcat 6 instance.
|
name |
Logical name of this Engine, used in log and error messages. When using muliple Service elements in the same Server, each Engine MUST be assigned a unique name.
|
tomcat 官方对Host标签的说明:
AttributeDescription
appBase |
The Application Base directory for this virtual host. This is the pathname of a directory that may contain web applications to be deployed on this virtual host. You may specify an absolute pathname for this directory, or a pathname that is relative to the $CATALINA_BASE directory. See Automatic Application Deployment for more information on automatic recognition and deployment of web applications to be deployed automatically.
|
autoDeploy |
This flag value indicates if new web applications, dropped in to the appBase directory while Tomcat is running, should be automatically deployed. The flag's value defaults to true. See Automatic Application Deployment for more information.
|
backgroundProcessorDelay |
This value represents the delay in seconds between the invocation of the backgroundProcess method on this host and its child containers, including all contexts. Child containers will not be invoked if their delay value is not negative (which would mean they are using their own processing thread). Setting this to a positive value will cause a thread to be spawn. After waiting the specified amount of time, the thread will invoke the backgroundProcess method on this host and all its child containers. A host will use background processing to perform live web application deployment related tasks. If not specified, the default value for this attribute is -1, which means the host will rely on the background processing thread of its parent engine.
|
className |
Java class name of the implementation to use. This class must implement the org.apache.catalina.Host interface. If not specified, the standard value (defined below) will be used.
|
deployOnStartup |
This flag value indicates if web applications from this host should be automatically deployed by the host configurator. The flag's value defaults to true. See Automatic Application Deployment for more information.
|
name |
Network name of this virtual host, as registered in your Domain Name Service server. One of the Hosts nested within an Engine MUST have a name that matches the defaultHost setting for that Engine. See Host Name Aliases for information on how to assign more than one network name to the same virtual host.
|
最后,便可以通过http://localhost/进行访问了.
如果要添加其它应用,则将应用部署在appBase指定的目录,记得在应用的META-INF目录中添加"应用名.xml"就可以了.
当然,如:faceye.xml.那么,将来的访问就为:http://localhost/faceye.
分享到:
相关推荐
用于配置 tomcat-redis-session-manager
包括commons-pool-1.6.jar,jedis-2.0.0.jar,tomcat-redis-session-manager-1.2-tomcat-6&7.jar
tomcat-redis-session-manager-2.0.0.jar,可用于Tomcat8下Redis的Session共享,亲测可用,还需要下载另外两个jar包:commons-pool2-2.4.2.jar和jedis-2.9.0.jar,maven仓库有,此处不再上传
Apache-tomcat-7.0.109-Windows-x64
tomcat 7 最新版本 apache-tomcat-7.0.109
Tomcat7下载(apache-tomcat-7.0.85)Tomcat7下载(apache-tomcat-7.0.85)Tomcat7下载(apache-tomcat-7.0.85)Tomcat7下载(apache-tomcat-7.0.85)
Tomcat虚拟主机配置
tomcat-redis-session-manager-1.2.jar redis+tomcat session共享需要的jar包,包括tomcat6和tomcat7
tomcat-redis-session-manager-master为tomcat集群分布式session分享功能,详细信息见http://blog.csdn.net/fengshizty?viewmode=list对应内容
liunx下tomcat、mysql配置!!liunx下tomcat、mysql配置!!liunx下tomcat、mysql配置!!
apache-tomcat-7.0.53apache-tomcat-7.0.53apache-tomcat-7.0.53apache-tomcat-7.0.53
适合apache tomcat 7,在tomcat-7.0.57通过,解决java.lang.UnsatisfiedLinkError: D:\vleyong\tomcat-7.0.57\bin\tcnative-1.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform这个问题的dll文件
Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选。对于一个初学者来说,可以这样认为,当在一台...
经历过几次的失败 这儿是经验 只需四步 轻松简单安装并且配置好开发环境所需要的tomcat
tomcat6的log4j配置所需要的jar包、日志分割 准备三个包:log4j-1.2.17.jar tomcat-juli.jar tomcat-juli-adapters.jar 放到tomcat的lib目录或者是工程的WEB_INF/lib下
tomcat6-dta-ssl-1.0.0.jar 此类文件将有助于tomcat支持ssl协议
文件包括tomcat-9.0.37的windows版的安装程序,是一个zip压缩文件,还有一份安装和配置的pdf说明文件。 个人博客地址:https://blog.csdn.net/Albert201605
tomcat-redis-session-manager-1.2-tomcat-7.jar
实现多个tomcat之间session共享问题,将此jar包放入tomcat lib目录,并在content.xml中配置如下: <Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" /> ...
tomcat-juli.jar,tomcat-juli-adapters.jar, log4j-1.2.12.jar tomcat 6日志输出