Search:  
Gentoo Wiki

Tomcat_5_Install

Contents

Introduction to Tomcat

This wiki will show you how to install the Jakarta Project's Tomcat 5.5 on Gentoo. Tomcat is a servlet container which allows the execution of Java Servlets and JavaServer Pages. Both provide an excellent platform for creating dynamic content. But Tomcat can do much more than just host servlets or JSP's for you. For instance, it can host HTML, PHP and PERL and do about anything a normal webserver can. But if you still prefer Apache, Tomcat can also be configured to work together with Apache (see mod_jk). Then if for some obscure reason your questions aren't answered here please check the Tomcat Website or the Tomcat Wiki.
Then, at last, I will opt some alternatives to Tomcat. Just incase you want something to compare it to.


Since there are many different servlet engine implementations I will not give you a complete list. If you really miss your favorite servlet engine please add it ... That is the whole idea of a wiki :D You could also check this list at Sun or this list at the Wikipedia

Installing Tomcat 5.5

Installation takes only a simple emerge:

 emerge -av tomcat

Note: If you are using Apache or Apache2, you may want to add the corresponding USE variables to your /etc/make.conf. Also, if you want the admin webapp, make sure also to use the 'admin' USE flag for tomcat.

Starting & Testing Tomcat 5.5

To start Tomcat 5.5 run:

 /etc/init.d/tomcat-5.5 start 

To see if Tomcat 5.5 is functioning properly browse to http://localhost:8080/manager/manager-howto.html (since by default Tomcat5 listens on port 8080 and there is no default website installed when you installed tomcat without the "examples" in the correspondent USE variable).

Configuring Tomcat 5.5

Configuring Tomcat 5.5 to Start on Boot

To make Tomcat 5.5 start everytime you reboot your machine:

 rc-update add tomcat-5.5 default

Changing the webapps Directory

To change the webapps directory in Tomcat 5.5 you need to create a new symlink. But we start by creating the new data directory and copying the default webapps data into the new dir.

Creating the new webapps dir (In this example I use "/data/tomcat/webapps")

 mkdir -p /data/tomcat/webapps

Move the data from the default webapps dir into the new dir:

 cp -R /usr/share/tomcat-5.5/server/webapps/* /data/tomcat/webapps
 rm -R /usr/share/tomcat-5.5/server/webapps

(Note it can be done in one command but this is the safer way if your hardware is crappy)

Create a new symbolic link to the new webapps dir:

 ln -s /data/tomcat/webapps /usr/share/tomcat-5.5/server/webapps

Now restart tomcat to reload the configuration:

/etc/init.d/tomcat-5.5 restart

Configuring Manager Application Access

This is the short version of how to get into the Manager Web Application. If you want to know how to use it I suggest you read this page http://localhost:8080/manager/manager-howto.html . But if you are just intrested in getting in to take a quick look read on

Open the Tomcat users file

  nano -w /etc/tomcat-5.5/tomcat-users.xml

Create the role "manager":

 <tomcat-users>
   ...
   <role rolename="manager"/>
   ...
 </tomcat-users>

Create a user and give him the "manager" role

 <tomcat-users>
   ...
   <user username="LetMeIn" password="secret" roles="manager"/>
   ...
 </tomcat-users>

Restart tomcat

 /etc/init.d/tomcat-5.5 restart

Then go to http://localhost:8080/manager/status and use your freshly created user to login

Configuring Admin Application Access

This is the short version of how to get into the Admin Web Application. If your have read the Manager section it will look very familiar.

Open the Tomcat users file

 nano -w /etc/tomcat-5.5/tomcat-users.xml

Create the role "admin":

 <tomcat-users>
   ...
   <role rolename="admin"/>
   ...
 </tomcat-users>

Create a user and give him the "admin" role

 <tomcat-users>
   ...
   <user username="LetMeIn" password="secret" roles="manager,admin"/>
   ...
 </tomcat-users>

Restart tomcat

 /etc/init.d/tomcat-5.5 restart

Then go to http://localhost:8080/admin/ and use your freshly created user to login

Memory Minimum and Maximum Settings

The following settings will prevent accumulating Java Memory Leaks from consuming all your memory

 nano -w /etc/conf.d/tomcat-5.5

Uncomment (remove the '#') the JAVA_OPT line and change it to

 JAVA_OPTS="-ms64M -mx256M"
Note: It is recommended now to use new versions of those switches, like that: -Xms64m -Xmx256m. For the time being they have same effect and are doing exectly same thing, but those "not -X" options are kept around for backward compatibility reasons and they might be removed at any time.

--m3q 11:47, 2008-06-13 (GMT)

Finishing Up

That's it! Tomcat 5.5 is now configured and ready to host whatever webpages you had in mind. If if you wish to run Tomcat 5.5 alone as a webserver you may want to learn about redirecting port 80 to port 8080 in the wiki on iptables. Please keep this page up to date (I recently updated it from tomcat 5 to tomcat 5.5) and add other usefull settings if you find/use them.

--DouweQuerty 23:44, 2 oktober 2006 (UTC)

Retrieved from "http://www.gentoo-wiki.info/Tomcat_5_Install"

Last modified: Fri, 05 Sep 2008 22:26:00 +0000 Hits: 10,181