Tomcat 5.5 for Ubuntu Quickstart Guide

Apache Tomcat is a web container developed at the Apache Software Foundation (ASF). Tomcat implements the servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, providing an environment for Java code to run in cooperation with a web server.

Installing Tomcat for Ubuntu

$ sudo apt-get install tomcat5.5

Starting and Stopping Tomcat

The /etc/init.d/tomcat5.5 script and the following options {start | stop | restart | try-restart | force-reload | status} is use to control the server.

Directories and Configuration Files

  • /etc/tomcat5.5 Configuration directory for Tomcat
  • /var/lib/tomcat5.5 Base directory (CATALINA_BASE) for Tomcat
  • /usr/share/tomcat5.5 Home directory (CATALINA_HOME) for Tomcat

The default configuration can be found at /etc/default/tomcat5.5 as well the directory /etc/tomcat5.5 contains other configuration files:

  • server.xml The server configuration file for Tomcat.
  • web.xml The default deployment descriptor.
  • policy.d This directory contains several policy files for SecurityManager. During start up these files will be appended together to auto generate the catalina.policy in the $CATALINA_BASE/conf/ directory.

Running Tomcat’s Servlet and JSP Examples

To install Tomcat’s example applications

$ apt-get install tomcat5.5-webapps

The examples will be installed in the /usr/share/tomcat5.5-webapps directory. To view the examples point your browser to http://localhost:8180, where 8180 is the default port for the Tomcat installation. To change it, modify the HTTP Connector in the server.xml file:

<Connector port="8180" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" />

For more information on the HTTP Connector refer to http://tomcat.apache.org/tomcat-5.5-doc/config/http.html

Enabling/Disabling SecurityManager

The default installation of Tomcat has SecurityManager is enabled in the startup script. To enable/disable SecurityManager edit the file /etc/init.d/tomcat5.5 and set the variable TOMCAT5_SECURITY to yes/no.

An alternative is to modified the file /etc/default/tomcat5.5.

Defining Virtual Host

To define a new virtual host modify the server.xml and add a new host inside the Catalina Engine container.

<Engine name="Catanlina" defaultHost="localhost">
    <Host name="www.example.com" appBase="/path/to/webapp"
     unpackWARs="true" autoDeploy="true"
     xmlValidation="false" xmlNamespaceAware="false">
        <Alias>example.com</Alias>
        <Context path="/" docBase="/example"/>
     </Host>
</Engine>

If the Context is not defined the default docBase would be ROOT, i.e. you will need to deploy you application in /path/to/webapp/ROOT.

For more information on the Host configuration attributes refer to http://tomcat.apache.org/tomcat-5.5-doc/config/host.html.
For more informaton on the Context configuration attributes refer to http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

Related posts:

  1. Apache for Ubuntu Quickstart Guide
  2. Integrating Tomcat and Apache Using Proxy
  3. Integrating Tomcat and Apache with mod_jk Connector
  4. Tomcat 5.5 Doesn’t Start in Ubuntu 7.10
  5. Problems with Ubuntu 7.10 and Tomcat 5.5
This entry was posted in Tomcat, Ubuntu and tagged , . Bookmark the permalink.

Comments are closed.