0

The Resin configuration (resin.xml) pasted below achieves the following:

  1. Binds the built-in http server to port 8000
  2. Sets the desired maximum memory allocation (-Xmx512m)
  3. Configures the webapp /path/web/root accessible from http://domain.com and http://(www|www1|www2).domain.com
  4. 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?
knorv
  • 1,799
  • 6
  • 19
  • 29

1 Answers1

1

I can answer some of these questions.

Changing the port number is done by editing the appropriate <Connector /> element in the conf/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:

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

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 to bin/startup.sh:

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

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:

<!-- 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"/>
-->

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 :-).

Matt Solnit
  • 913
  • 2
  • 11
  • 16