什么是这个树脂configuration等效的Tomcat设置?

下面粘贴的树脂configuration( resin.xml )可实现以下function:

  1. 将内置的http服务器绑定到端口8000
  2. 设置所需的最大内存分配( -Xmx512m
  3. configuration可从http://domain.comhttp://(www|www1|www2).domain.com访问的webapp / path / web / root
  4. 将访问日志logging设置为/path/to/logs/access.log

这是树脂configuration:

 <resin> <cluster id="app-tier"> <server-default> <!-- #1 --> <http port="8000"/> <!-- #2 --> <jvm-arg>-Xmx512m</jvm-arg> </server-default> <!-- #3 --> <host id='domain.com' root-directory="/path/web/root"> <web-app id="/" /> <!-- #3 --> <host-alias-regexp>(www|www1|www2).domain.com</host-alias-regexp> <!-- #4 --> <access-log path="/path/to/logs/access.log" /> </host> </cluster> </resin> 

我正在从Resin切换到Tomcat,因此我的问题是:

  • Tomcat实现上述四件事情的“最佳实践configuration”是什么?

我可以回答其中的一些问题。

通过编辑conf/server.xml文件中相应的<Connector />元素来更改端口号(请参阅http://tomcat.apache.org/tomcat-6.0-doc/config/http.html以获取更多信息&#xFF09; 。

这是什么出来的框中:

 <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 

您可以将port属性更改为任何您想要的。

可以使用JAVA_OPTS环境variables来更改堆大小或其他任何JVM设置。 例如,您可以将以下内容添加到bin/startup.sh

 # Must go *before* the final line ("exec ...") export JAVA_OPTS="$JAVA_OPTS -Xmx512m" 

我从来没有设置过访问日志。 但是,您可以通过在conf/server.xml取消注释适当的“Valve”来实现(详情请参阅http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html ) 。

从我的server.xml文件注释阀的示例:

 <!-- Access log processes all example. Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/> --> 

最后,对于虚拟主机,我只能指向你的文档,这是在http://tomcat.apache.org/tomcat-6.0-doc/config/host.html 。 我希望这比什么都好—)。