This howto outlines the installation, configuration
and starting/stopping of Jakarta Tomcat on Unix and
Win32 platforms.
The example specifically shows version 3.3.1
(other versions are similar)
and assumes that a Java JDK is installed in
/opt/pkg/jdk (Unix) or
C:\jdk (Win32).
Use gunzip to extract the files from the
tomcat distribution into a directory.
Here we have done this to the
/opt/pkg directory.
The files are then extracted into the
/opt/pkg/jakarta-tomcat-3.3.1
directory.
We then set this directory path into the
TOMCAT_HOME variable which
is used throughout this example.
$ cd /opt/pkg
$ gunzip -c /tmp/jakarta-tomcat-3.3.1.tar.gz | tar xvf -
$ TOMCAT_HOME="/opt/pkg/jakarta-tomcat-3.3.1"
$ export TOMCAT_HOME
$ cd "${TOMCAT_HOME}"
Win32
Use winzip (or a program like winzip) to extract
the files from the distribution into a directory.
Here we have done this to the root directory of
the C drive (C:\).
The files are then extracted into the
C:\jakarta-tomcat-3.3.1
directory.
We then set this directory path into the
TOMCAT_HOME variable which
is used throughout this example.
C:\> set TOMCAT_HOME=C:\jakarta-tomcat-3.3.1
C:\> cd %TOMCAT_HOME%
C:\jakarta-tomcat-3.3.1>
By default Tomcat will start on port 8080.
If you wish to change this you must edit
TOMCAT_HOME/conf/server.xml file.
The section that contains port="8080"
should be changed to the port number you require.
Note: that on Unix systems you
will need to have super-user privileges to start
Tomcat when you have configured a port less than
1024.
In this section we will demonstrate adding an sample
application, for this we will use Ozibug.
To quickly add an application, it can be done in
the TOMCAT_HOME/webapps directory.
Tomcat searches this directory each time it starts
and adds any applications it finds to its configuration,
so there is no need to change the
TOMCAT_HOME/conf/server.xml file.
Unix
Create the ozibug directory inside the webapps
directory and then use unzip to extract the
files from the distribution into this directory.
We then copy in a license file.
$ cd "${TOMCAT_HOME}/webapps"
$ mkdir ozibug
$ cd ozibug
$ unzip /tmp/ozibug-1.1.0.war
$ cp /tmp/License.ser WEB-INF/License.ser
Win32
Create the ozibug directory inside the webapps
directory and then copy in the license file,
we assume this is already in the
C:\Temp directory.
C:\> cd %TOMCAT_HOME%\webapps
C:\jakarta-tomcat-3.3.1\webapps> mkdir ozibug
C:\jakarta-tomcat-3.3.1\webapps> cd ozibug
C:\jakarta-tomcat-3.3.1\webapps\ozibug> mkdir WEB-INF
C:\jakarta-tomcat-3.3.1\webapps\ozibug> cd WEB-INF
C:\jakarta-tomcat-3.3.1\webapps\ozibug\WEB-INF> copy C:\Temp\License.ser .
Now use a program such as winzip to extract
the files from the distribution into the
directory.
To start and stop tomcat we must set two variables.
We have already seen that the
TOMCAT_HOME variable
is set to the base directory of the jakarta tomcat
installation.
The JAVA_HOME variable is
set to the base directory of your java installation.
C:\> set TOMCAT_HOME=C:\jakarta-tomcat-3.3.1
C:\> set JAVA_HOME=C:\jdk
Once the variables have been set then it is
a straight forward task to change to the
TOMCAT_HOME\bin directory
and call the tomcat.[sh|bat]
file with the start parameter.
Unix
$ cd "${TOMCAT_HOME}/bin"
$ ./tomcat.sh start
Win32
C:\> cd %TOMCAT_HOME%\bin
C:\jakarta-tomcat-3.3.1\bin> tomcat start
To stop tomcat change to the
TOMCAT_HOME\bin directory
and call the tomcat.[sh|bat]
file with the stop parameter.
Unix
$ cd "${TOMCAT_HOME}/bin"
$ ./tomcat.sh stop
Win32
C:\> cd %TOMCAT_HOME%\bin
C:\jakarta-tomcat-3.3.1\bin> tomcat stop
Once tomcat has been successfully started then
you can try the following URLs in your web
browser.
The first URL accesses the default documentation
that comes with Tomcat. The second URL is the index
page of the web application (Ozibug) we installed.
Note: that localhost
only applies if the browser is on the same machine
that you installed Tomcat on. Otherwise this should
be the fully qualified name of the machine that you
installed and started Tomcat on.
Note: that 8080
is the port number that Tomcat is using to listen
for HTTP requests on. If you configured a different
port then this should be changed to that.