Personal tools
You are here: Home Leocornus Leocornus Buildout Config Repository. Buildout to Setup Standalone Tomcat Instance

Buildout to Setup Standalone Tomcat Instance

quick list:

  • download and install JDK/JRE
  • download and install Tomcat
  • create CATALINA_BASE for the tomcat instance.
    • bin/setenv.sh
      -- optional for set up environment variables. It is the same with Supervisor environment option.
    • conf
    • webapps
    • logs
      -- the log files, specified in server.xml file.
    • temp
    • work
      -- the runtime work directory, configed in server.xml file.
  • generate catalina configration files, in folder CATALINA_BASE/conf:
    • server.xml
    • context.xml
    • web.xml
    • tomcat-users.xml
    • logging.properties
    • catalina.policy
    • catalina.properties
  • setup the supervisor program configrations.
    • using the environment to set CATALINA_HOME and CATALINA_BASE. Maybe also JAVA_HOME.

About Tomcat Configuration

There are 4 important configuration files for a Tomcat instance: server.xml, context.xml, logging.properties, and web.xml. The following are brief descriptions for each files:

  • server.xml
    It is located in CATALINA_BASE/conf. It will define the Server, Service, Connectors, Engines, Hosts, etc.
  • web.xml
    This file will set the default values for all Web applications in this instance Such as mime mapping, default servlets, session timeout, etc. We will copy from the Tomcat installation for now.
  • logging.properties
    We will copy is from the Tomcat installation for now.
  • context.xml
    Context is related the Service, Engine, and Host settings in Server.xml.

Folder Structure in Buildout

One buildout config to download and install Java and Tomcat distribution. A separate buildout config to do the configuration.

  • java-build.cfg
    • java-build
    • tomcat-build
    • solr-build
  • tomcat-conf.cfg
    • catalina-base
      -- create a catalin base folder
    • tomcat-conf
      -- all configurations about tomcat instance
  • solr-conf.cfg

We will set the catalina base to var/catalina

Java Web Containers

Try to figure out which is Java Web container is better: Tomcat, Jetty, Caucho Resin?

Google choses Jetty for App Engine: http://www.infoq.com/news/2009/08/google-chose-jetty.

Google groupd discussion: Tomcat VS Jetty.

Tomcat, Nginx and Varnish

There are 2 ways for Nginx connect to Tomcat: Proxy and AJP. Nginx built-in Proxy is the easy way to wire Nginx and Tomcat. It could as simple as following:

location /search {
    proxy_pass http://127.0.0.1:8088/solr-example;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

AJP connection depends on a 3rd party Nginx module. There is one on GitHub: nginx_ajp_module. AJP protocol promises better performance...

Some references: http://endofstream.com/installing-and-configuring-varnish/ http://blog.mgm-tp.com/2012/01/varnish-web-cache/

Document Actions