ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Installing and Configuring Tomcat
Pages: 1, 2, 3

Installing to Linux
The installation is much simpler on a Linux than a Windows machine. The first thing you need to do is install the JDK. For our purposes, we will assume that the JDK will be installed to /bob/java.



After you have the JDK installed, you need to set the JAVA_HOME environment variable. To do this under Linux, find your shell in Table 2 and type the matching command. You will need to replace /bob/java with the root location of your JDK installation.

Table 2. Java Environment Settings

Shell JAVA_HOME
bash
JAVA_HOME=/bob/java
tcsh
setenv JAVA_HOME /bob/java

You should add the location of the Java interpreter to your PATH environment variable.

You now need to extract the Tomcat server to a directory of your choosing. This directory will become the TOMCAT_HOME directory. For this installation, we will assume that Tomcat will be installed to /bob/jakarta-tomcat-4.0-b1.

The last step is to set the TOMCAT_HOME environment variable. To do this under Linux, find your shell in Table 3 and type the matching command. You will need to replace /bob with the name of the directory located directly above your Tomcat installation.

Table 3. Tomcat Environment Settings

Shell TOMCAT_HOME
bash
TOMCAT_HOME=/bob/jakarta-tomcat-4.0-b1
export TOMCAT_HOME
tcsh
setenv TOMCAT_HOME /bob/jakarta-tomcat-4.0-b1

Testing Your Tomcat Installation

To test the Tomcat installation, first start the Tomcat server. Table 4 contains the startup and shutdown commands for each OS.

Table 4. Tomcat Startup/Shutdown Commands

OS Startup Shutdown
Windows NT/2000 TOMCAT_HOME\bin\startup.bat TOMCAT_HOME\bin\shutdown.bat
Linux TOMCAT_HOME/bin/startup.sh TOMCAT_HOME/bin/shutdown.sh

Once Tomcat has started, point your browser at

http://localhost:8080/

You should see a page similar to Figure 5.

Screen shot.
Figure 5. The Tomcat Default Page

If you would like to have all requests serviced on the default HTTP port of 80, instead of port 8080, you will need to make the following change to the TOMCAT_HOME/conf/server.xml file and restart Tomcat.

Change

<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8080" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>

to

<!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="80" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>

Now point your browser at

http://localhost/

and you'll see results similar to those in Figure 5.

The next step is to verify the installation of your JDK, which is done by executing one of the JSP examples provided with the Tomcat server. At the page shown in Figure 5, choose JSP Examples. You should see a page similar to Figure 6.

Screen shot.
Figure 6. The JSP Examples Page

Now choose the JSP example Date and select the Execute link. If everything was installed properly you should see a page similar to Figure 7 (of course with a different date).

Screen shot.
Figure 7 The JSP Date Page

If you do not see the previous page, then you need to make sure that the location of your JAVA_HOME environment variable matches the location of your JDK installation.

Pages: 1, 2, 3

Next Pagearrow