How to Apache-Tomcat on Linux

What is Tomcat

Tomcat is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed by Sun under the Java Community Process.

From the authors point of view: –tomcat.apache.org
Prerequisites
– java

Download java

Go to http://java.sun.com/javase/downloads/?intcmp=1281 choose your platform and follow the steps on the site.

Installing the binaries
The installation of the Java Developer’s Kit is pretty straightforward if if you retrieve the RPM for it. If you have to download the RPM from Sun’s site, it isn’t acutally in RPM format yet. It’ll be called something like j2sdk-xxx-linux-rpm.bin. chmod 700 it and execute it. This will run the Sun EULA and after you agree to it, generate the actual RPM file.

Execute the binary:
chmod +x jdk-xxx-linux-i586-rpm.bin

After the RPM is produced, install it simply by running rpm -ivh jdk-xxx-linux-i586-rpm. This will install the JDK in /usr/java/jdk.x.x.  You need to modify the user’s .bash_profile to include /usr/java/jdk/bin in the path so the executables will run. What I usually do is make a symbolic link called /usr/java/jdk that points to this /usr/java/jdk.x.x. That way I don’t have to update my path in the .bash_profile every time I install a new version of the JDK.

You should also set your JAVA_HOME in the .bash_profile with something like  export JAVA_HOME=/usr/java/jdk
or on bash promt of user

[root@localhost]# JAVA_HOME=/usr/java/jdk; export JAVA_HOME

Download the latest stable release of tomcat from http://mirrors.24-7-solutions.net/pub/apache/tomcat/tomcat-5/v5.5.26/bin/apache-tomcat-5.5.26.tar.gz

after downloading apache-tomcat-5.x.x.tar.gz extract it into /usr/local/

Installing the binaries
cd /usr/local

tar -xvzf apache-tomcat-5.x.x.tar.gz

cd apache-tomcat-5.x.x

cd bin

rm *.bat

To enable the Tomcat manager, you need to modify /usr/local/apache-tomcat-5.x.x/conf/tomcat-users.xml add a user »admin« or with the role »manager«. The result should look like this:

<?xml version=’1.0′ encoding=’utf-8′?>
<tomcat-users>
<role rolename=”manager”/>
<role rolename=”tomcat”/>
<role rolename=”role1″/>
<user username=”both” password=”tomcat” roles=”tomcat,role1″/>
<user username=”tomcat” password=”tomcat” roles=”tomcat”/>
<user username=”admin” password=”password” roles=”manager”/>
<user username=”role1″ password=”tomcat” roles=”role1″/>
</tomcat-users>

Now you should be able to startup tomcat:

/bin/sh /usr/local/apache-tomcat-5.x.x/bin/startup.sh

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

Thanks

Ravi

Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s