FROM : https://help.ubuntu.com/9.10/serverguide/C/tomcat.html
Apache Tomcat
Apache Tomcat is a web container that allows you to serve Java Servlets
and JSP (Java Server Pages) web applications.
The Tomcat 6.0 packages in Ubuntu support
two different ways of running Tomcat. You can install them as a classic
unique system-wide instance, that will be started at boot time and will run
as the tomcat6 unpriviledged user. But you can also deploy private
instances that will run with your own user rights, and that you should
start and stop by yourself. This second way is particularly useful in a
development server context where multiple users need to test on their own
private Tomcat instances.
System-wide installation
To install the Tomcat server,
you can enter the following command in the terminal prompt:
<span class="command"><strong>sudo apt-get install tomcat6</strong></span>
This will install a Tomcat server with just a default ROOT webapp
that displays a minimal "It works" page by default.
Configuration
Tomcat configuration files can be found in
/etc/tomcat6. Only a few common configuration tweaks
will be described here, please see
Tomcat
6.0 documentation for more.
Changing default ports
By default Tomcat 6.0 runs a HTTP connector on port 8080 and an
AJP connector on port 8009. You might want to change those default
ports to avoid conflict with another server on the system. This is
done by changing the following lines in
/etc/tomcat6/server.xml:
<Connector port="8080" protocol="HTTP/1.1" <br /> connectionTimeout="20000" <br /> redirectPort="8443" /><br />...<br /><Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /><br />
Changing JVM used
By default Tomcat will run preferably with OpenJDK-6, then try
Sun's JVM, then try some other JVMs. If you have various JVMs
installed, you can set which should be used by setting JAVA_HOME in
/etc/default/tomcat6:
JAVA_HOME=/usr/lib/jvm/java-6-sun<br />
Declaring users and roles
Usernames, passwords and roles (groups) can be defined centrally
in a Servlet container. In Tomcat 6.0 this is done in the
/etc/tomcat6/tomcat-users.xml file:
<role rolename="admin"/><br /><user username="tomcat" password="s3cret" roles="admin"/><br />
Using Tomcat standard webapps
Tomcat is shipped with webapps that you can install
for documentation, administration or demo purposes.
Tomcat documentation
The tomcat6-docs package contains
Tomcat 6.0 documentation, packaged as a webapp that you can access by
default at http://yourserver:8080/docs. You can install it by entering
the following command in the terminal prompt:
<span class="command"><strong>sudo apt-get install tomcat6-docs</strong></span><br />
Tomcat administration webapps
The tomcat6-admin package contains
two webapps that can be used to administer the Tomcat server using a
web interface. You can install them by entering the
following command in the terminal prompt:
<span class="command"><strong>sudo apt-get install tomcat6-admin</strong></span><br />
The first one is the manager webapp, which
you can access by default at http://yourserver:8080/manager/html. It is
primarily used to get server status and restart webapps.
![]() | |
Access to the manager application is |
The second one is the host-manager webapp,
which you can access by default at
http://yourserver:8080/host-manager/html.
It can be used to create virtual hosts dynamically.
![]() | |
Access to the host-manager application is |
For security reasons, the tomcat6 user cannot write to the
/etc/tomcat6 directory by default. Some features
in these admin webapps (application deployment, virtual host creation)
need write access to that directory. If you want to use these
features execute the following, to give users in the tomcat6 group the necessary
rights:
<span class="command"><strong>sudo chgrp -R tomcat6 /etc/tomcat6</strong></span><br /><span class="command"><strong>sudo chmod -R g+w /etc/tomcat6</strong></span> <br />
![[Note]](https://help.ubuntu.com/9.10/libs/admon/note.png)