The Resin configuration (resin.xml
) pasted below achieves the following:
- Binds the built-in http server to port 8000
- Sets the desired maximum memory allocation (
-Xmx512m
) - Configures the webapp /path/web/root accessible from
http://domain.com
andhttp://(www|www1|www2).domain.com
- Sets up access logging to /path/to/logs/access.log
This is the Resin 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>
I'm switching from Resin to Tomcat and my question is hence:
- What is the "best practice configuration" for Tomcat to achieve the four things outlined above?
I can answer some of these questions.
Changing the port number is done by editing the appropriate
<Connector />
element in theconf/server.xml
file (see http://tomcat.apache.org/tomcat-6.0-doc/config/http.html for more information).Here is what comes out of the box:
You could change the
port
attribute to anything you want.Changing the heap size, or any other JVM setting, can be done using the
JAVA_OPTS
environment variable. For example, you could add the following tobin/startup.sh
:I have never set up an access log before. However, it looks like you can do it by un-commenting the appropriate "Valve" in
conf/server.xml
(see http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html for details).Example of the commented-out valve from my
server.xml
file:Lastly, for virtual hosts, I can only point you to the documentation, which is at http://tomcat.apache.org/tomcat-6.0-doc/config/host.html. I hope this is better than nothing :-).