Install Tomcat

From OpenFSG
Jump to: navigation, search

This page explains how to install and run the Apache-Tomcat on the FSG.


Contents

General Info about the Apache Tomcat

Tomcat is a Java-based WEB-Server that brings the ability to run Java-Server-Pages (.jsp) and servlets. Java-Server-Pages are text-based HTML-Pages with pieces of Java-Code. The extension is HTML-Textfile.jsp. Before a JSP can be displayd by the browser, it has to be compiled by the tomcat-own Java-Compiler JASPER. Therefore it takes quite a long time from the request of a JSP to its appearence. Servlets are Java-Classes which are able to handle HTTP-Requests and HTTP-Responses. Commonly the JSP fit the graphical Front-End of a Java-based WEB-Application. The servlets cover the buisiniss-logic of the WEB-Application. To run Tomcat on a server provide the existence of a JAVA-Virtual-Machine (jvm).

These instructions assume that you are using the 4.4.5 firmware. Furthermore the bash should be installed (simply ipkg install bash). The following steps are described:


Installing the JVM

The necessary components for the Java-Environment are all available in Optware-Packets and are to be installed as follows:

ipkg install classpath
ipkg install jamvm
ipkg install jikes
ipkg install zlib
ipkg install file

If you get stuck with this action, read the following article : [1]

Installing and configuring Apache-Tomcat

The Tomcat-Version has to be the tomcat 5.0.30beta (this is the last Tomcat-Version, wich doesn't require java 1.5) and is available in the Tomcat archive. It is packed in a tar-file and has to be unpacked on any folder on the fsg. I prefer /opt/tomcat

tar -zxvf apache-tomcat-5.0.30.tar.tar

After having unpacked the archive try

ls -l

should read like this:

/opt/tomcat/jakarta-tomcat-5.0.30 # ls -l
-rw-r--r-- 1 root root 11357 Nov 24 2004 LICENSE
-rw-r--r-- 1 root root 505   Nov 24 2004 NOTICE
-rw-r--r-- 1 root root 9249  Nov 24 2004 RELEASE-NOTES
-rw-r--r-- 1 root root 5887  Nov 24 2004 RUNNING.txt
drwxr-xr-x 3 root root 1352  Mar 6 02:41 bin
drwxr-xr-x 5 root root 120   Mar 6 00:01 common
drwxr-xr-x 3 root root 304   Mar 6 04:26 conf
drwxr-xr-x 2 root root 152   Mar 6 02:37 logs
drwxr-xr-x 5 root root 120   Mar 6 00:01 server
drwxr-xr-x 4 root root 96    Mar 6 00:01 shared
drwxr-xr-x 2 root root 48    Nov 24 2004 temp
drwxr-xr-x 8 root root 224   Mar 6 00:01 webapps
drwxr-xr-x 3 root root 72    Mar 6 02:17 work
/opt/tomcat/jakarta-tomcat-5.0.30 #

The server.xml in conf-directory is used to initialize the Tomcat when it starts. By default, this file contains a lot of overhead and should be replaced with a minimal configuration.

cd conf
<Server port="8005" shutdown="SHUTDOWN" debug="0">
	<!-- Global JNDI resources -->
	<GlobalNamingResources>
	<!-- Test entry for demonstration purposes -->
	<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
	<!-- Editable user database that can also be used by
	     UserDatabaseRealm to authenticate users -->
	<Resource name="UserDatabase" auth="Container"
		type="org.apache.catalina.UserDatabase"
	 description="User database that can be updated and saved">
	</Resource>
	<ResourceParams name="UserDatabase">
		<parameter>
			<name>factory</name>
			<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
		</parameter>
		<parameter>
			<name>pathname</name>
			<value>conf/tomcat-users.xml</value>
		</parameter>
	</ResourceParams>
	</GlobalNamingResources>
	<Service name="Catalina">
		<Connector port="8080"
		maxThreads="15" minSpareThreads="1" maxSpareThreads="10"
		enableLookups="false" redirectPort="8443" acceptCount="100"
		debug="0" connectionTimeout="20000" 
		disableUploadTimeout="true" />
	<!-- Define the top level container in our container hierarchy -->
		<Engine name="Catalina" defaultHost="localhost" debug="0">
			<!-- Global logger unless overridden at lower levels -->
			<Logger className="org.apache.catalina.logger.FileLogger"
				prefix="catalina_log." suffix=".txt"
				timestamp="true"/>
			<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
				debug="0" resourceName="UserDatabase"/>
			<Host name="localhost" debug="0" appBase="webapps"
				unpackWARs="true" autoDeploy="true"
				xmlValidation="false" xmlNamespaceAware="false">
				<Logger className="org.apache.catalina.logger.FileLogger"
					directory="logs" prefix="localhost_log." suffix=".txt"
					timestamp="true"/>
			</Host>
		</Engine>
	</Service>
</Server>

Make Tomcat run on the FSG

#!/bin/sh
PATH=/usr/local/bin:$PATH
CATALINA_HOME=/opt/tomcat/jakarta-tomcat-5.0.30
CLASSPATH=/opt/share/jamvm/classes.zip:"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar
CATALINA_BASE="$CATALINA_HOME"
CATALINA_TMPDIR="$CATALINA_HOME"/temp
jamvm -classpath "$CLASSPATH" \
-Dcatalina.base="$CATALINA_BASE" \
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
org.apache.catalina.startup.Bootstrap "$@" start
>> "$CATALINA_BASE"/logs/catalina.out 2>&1 &

It will take quite a lot of time until tomcat starts for the first time, there are some exceptions thrown by the JVM, don't mind for this time. If there are any problems, please refer to the following article: [2]

For further configuration and examples refer to the Tomcat-Documentation brought by itself.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox