Monday, January 30, 2012

Tomcat installation



Note
Tomcat6 and Tomcat7 cannot be installed at the same time as a Ubuntu service. You have to make a choice. Otherwise the apt-get command is going to give you a package dependency error on the second tomcat installation (whichever one it is). If you want to install both of them at the same time, the only option is to extract the compressed tar and not install - with either one or both the versions of Tomcat.

Installation

Tomcat 6 is available from the Ubuntu repository, so we can use apt-get to download and install the package for us.
cgirl@cgirl-Satellite-T135D:~$ sudo apt-get install tomcat6
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following extra packages will be installed:
  authbind libcommons-dbcp-java libcommons-pool-java libecj-java libtomcat6-java tomcat6-common
Suggested packages:
  libgeronimo-jta-1.0.1b-spec-java ecj libecj-java-gcj tomcat6-docs tomcat6-admin tomcat6-examples
  tomcat6-user libtcnative-1
The following NEW packages will be installed:
  authbind libcommons-dbcp-java libcommons-pool-java libecj-java libtomcat6-java tomcat6 tomcat6-common
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/4,633 kB of archives.
After this operation, 5,984 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Preconfiguring packages ...
Selecting previously deselected package libcommons-pool-java.
(Reading database ... 252142 files and directories currently installed.)
Unpacking libcommons-pool-java (from .../libcommons-pool-java_1.5.6-1_all.deb) ...
Selecting previously deselected package libcommons-dbcp-java.
Unpacking libcommons-dbcp-java (from .../libcommons-dbcp-java_1.4-1ubuntu1_all.deb) ...
Selecting previously deselected package libecj-java.
Unpacking libecj-java (from .../libecj-java_3.5.1-3_all.deb) ...
Selecting previously deselected package libtomcat6-java.
Unpacking libtomcat6-java (from .../libtomcat6-java_6.0.32-5ubuntu1.1_all.deb) ...
Selecting previously deselected package tomcat6-common.
Unpacking tomcat6-common (from .../tomcat6-common_6.0.32-5ubuntu1.1_all.deb) ...
Selecting previously deselected package tomcat6.
Unpacking tomcat6 (from .../tomcat6_6.0.32-5ubuntu1.1_all.deb) ...
Selecting previously deselected package authbind.
Unpacking authbind (from .../authbind_1.2.0build3_amd64.deb) ...
Processing triggers for ureadahead ...
Processing triggers for man-db ...
Setting up libcommons-pool-java (1.5.6-1) ...
Setting up libcommons-dbcp-java (1.4-1ubuntu1) ...
Setting up libecj-java (3.5.1-3) ...
Setting up libtomcat6-java (6.0.32-5ubuntu1.1) ...
Setting up tomcat6-common (6.0.32-5ubuntu1.1) ...
Setting up tomcat6 (6.0.32-5ubuntu1.1) ...

Creating config file /etc/default/tomcat6 with new version
Adding system user `tomcat6' (UID 117) ...
Adding new user `tomcat6' (UID 117) with group `tomcat6' ...
Not creating home directory `/usr/share/tomcat6'.
 * Starting Tomcat servlet engine tomcat6                                                          [ OK ]
Setting up authbind (1.2.0build3) ...

Tomcat is installed as a service.
cgirl@cgirl-Satellite-T135D:/etc/init.d$ ls -l tomcat6
-rwxr-xr-x 1 root root 7149 2011-09-15 05:46 tomcat6
cgirl@cgirl-Satellite-T135D:/etc/init.d$

Here are a few lines from the tomcat6 script shown above.
PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=tomcat6
DESC="Tomcat servlet engine"
DEFAULT=/etc/default/$NAME
JVM_TMP=/tmp/tomcat6-tmp

# Run Tomcat 6 as this user ID and group ID
TOMCAT6_USER=tomcat6
TOMCAT6_GROUP=tomcat6
# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
# defined in $DEFAULT)
JDK_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /u
sr/lib/j2sdk1.5-ibm"

# Directory where the Tomcat 6 binary distribution resides
CATALINA_HOME=/usr/share/$NAME
# Directory for per-instance configuration files and webapps
CATALINA_BASE=/var/lib/$NAME
# Define other required variables
CATALINA_PID="/var/run/$NAME.pid"
CATALINA_SH="$CATALINA_HOME/bin/catalina.sh"


From the above lines, we can conclude this is where Tomcat 6 is actually installed.
cgirl@cgirl-Satellite-T135D:/usr/share/tomcat6$ ls -l
total 16
drwxr-xr-x 2 root root 4096 2012-01-29 12:20 bin
-rw-r--r-- 1 root root   39 2011-09-15 05:46 defaults.md5sum
-rw-r--r-- 1 root root 1960 2011-09-15 05:46 defaults.template
drwxr-xr-x 2 root root 4096 2012-01-29 12:20 lib


We can also conclude that the following directory is where the configuration files and webapps reside.
cgirl@cgirl-Satellite-T135D:/var/lib/tomcat6$ ls -l
total 16
drwxr-xr-x 3 tomcat6 tomcat6 4096 2012-01-29 12:20 common
lrwxrwxrwx 1 root    root      12 2011-10-13 19:07 conf -> /etc/tomcat6
lrwxrwxrwx 1 root    root      17 2011-10-13 19:07 logs -> ../../log/tomcat6
drwxr-xr-x 3 tomcat6 tomcat6 4096 2012-01-29 12:20 server
drwxr-xr-x 3 tomcat6 tomcat6 4096 2012-01-29 12:20 shared
drwxrwxr-x 3 tomcat6 tomcat6 4096 2012-01-29 12:20 webapps
lrwxrwxrwx 1 root    root      19 2011-10-13 19:07 work -> ../../cache/tomcat6



The log file for the server is in this directory (the catalina.out file).
cgirl@cgirl-Satellite-T135D:/var/log/tomcat6$ ls -l
total 16
-rw-r--r-- 1 tomcat6 tomcat6 2253 2012-01-29 14:15 catalina.2012-01-29.log
-rw-r--r-- 1 tomcat6 tomcat6 1927 2012-01-30 19:13 catalina.2012-01-30.log
-rw-r--r-- 1 tomcat6 root    4180 2012-01-30 19:13 catalina.out
-rw-r--r-- 1 tomcat6 tomcat6    0 2012-01-29 12:20 localhost.2012-01-29.log
-rw-r--r-- 1 tomcat6 tomcat6    0 2012-01-30 00:52 localhost.2012-01-30.log

cgirl@cgirl-Satellite-T135D:/var/log/tomcat6$


Here's how a successful startup looks.
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
Jan 29, 2012 2:10:17 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor ROOT.xml
Jan 29, 2012 2:10:18 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 29, 2012 2:10:18 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 665 ms
Jan 29, 2012 2:15:49 PM org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
Jan 29, 2012 2:15:50 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Jan 29, 2012 2:15:50 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
Jan 30, 2012 12:52:57 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jan 30, 2012 12:52:57 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1367 ms
Jan 30, 2012 12:52:57 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jan 30, 2012 12:52:57 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
Jan 30, 2012 12:52:57 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor ROOT.xml
Jan 30, 2012 12:52:57 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 30, 2012 12:52:57 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 544 ms

 

Here's how a shutdown looks.
Jan 30, 2012 12:59:57 AM org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
Jan 30, 2012 12:59:58 AM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Jan 30, 2012 12:59:58 AM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080


Tomcat 6 configuration - server.xml, context.xml and web.xml

 In $CATALINA_BASE/conf, you can find these 3 files.

No comments:

Post a Comment