Monday, November 10, 2008

Install Tomcat on Linux

Install Tomcat (5.0.28) on Redhat Linux 8.0
November 10, 2008

Install java

Go to http://java.sun.com/
Download and install jdk. Newest version 1.3.1_01 (during the time it is first installed).
The file name is: j2sdk-1_3_1_01-linux-i386-rpm.bin (or something like that.)

feed it into a shell:

# chmod 700 j2sdk-1_3_1_01-linux-i386-rpm.bin
# j2sdk-1_3_1_01-linux-i386-rpm.bin

scroll through the license agreement, answer yes at the bottom, and it will unpack into jdk-1.3.1_01.i386.rpm

Install the rpm file:

# rpm -ivh jdk-1.3.1_01.i386.rpm

This will install the JDK in: /usr/java/jdk1.3.1_01

You need to modify the /etc/profile to include /usr/java/jdk.x.x/bin in the path, so that the executable will run.

Usually, to make a symble link called /usr/java/jdk:
# ln –s /usr/java/jsk.x.x /usr/java/jdk
This way we don’t need to update the path in the /etc/profile every time a new version of JDK is installed.
JAVA_HOME should alos be set up in the /etc/profile
Add line:
JAVA_HOME=/usr/java/jdk; export JAVA_HOME
Into /etc/profile


Install tomcat

Download the latest stable release of tomcat, I have got: jakarta-tomcat-5.0.28.tar.gz
And then extract it into /usr/local

# cd /usr/local
# tar zxvf jakarta-tomcat-5.0.28.tar.gz
For convenience,
# ln –s Jakarta-tomcat-5.0.28 tomcat

# cd tomcat
# cd bin
# rm *.bat

To enable the Tomcat manager, you need to modify /usr/local/jakarta-tomcat-5.0.28/conf/tomcat-users.xml add a user “admin” with the role “manager”. The result should look like this:










Now the tomcat should be able to be started:

# /usr/local/tomcat/bin/startup.sh

We should be able to connect to : http://localhost:8080/index.jsp

To stop tomcat:

# /usr/local/tomcat/bin/shutdown.sh

The default permissions in the binary directory for tomcat are wrong for some silly reason.

# cd $TOMCAT_HOME/bin
# chmod 744 *.sh

Set up environment variables

In the /etc/profile, add lines:

JAVA_HOME=/usr/java/jdk; export JAVA_HOME
CLASSPATH=/usr/java/jdk/lib:usr/java/jre/lib:/usr/java/jdk/src.zip; export CLASSPATH
CATALINA_HOME=/usr/local/tomcat; export CATALINA_HOME
CATALINA_BASE=/usr/local/tomcat; export CATALINA_BASE
PATH=$PATH:$JAVA_HOME/bin

Auto-Start tomcat

To start tomcat automatically when the Linux starts:

1.
Add lines:
JAVA_HOME=/usr/java/jdk
CATALINA_HOME=/usr/local/tomcat
In the Catalina.sh file, before the line: PRGDIR=’dirname “$PRG” ‘

2.
# cd /etc/rc.d/init.d
# cp /usr/local/tomcat/bin/Catalina.sh ./
# ln –s /etc/rc.d/init.d/catalina.sh /etc/rc.d/rc5.d/S81tomcat

No comments: