Google Site SearchFN Site Search FN Blog Login FN Blog Login
Site Navigation:
 
 

TUTORIAL: Jakarta-Tomcat 4

by Casper Pedersen on February 9, 2004

With this tutorial, I will try to give you the steps to build Jakarta Tomcat, as an RPM package. This will allow for easy deployment, with the use of mod_jk2 and Fedoras httpd (Apache2).

Also see this article about How to build Custom yum Repository which will make it even easier.

"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."

UPDATED 2004-03-13 I got an email from Jeff Carlson, which suggested some changes. Some of them would where quite good. a) how to check if the tomcat user/group exist - use getent instead of grep b) move the webapps directory to /var/www/webapps (probably not where he wanted it). I have modified the .spec file to reflect these changes. One thing - I have not tested what happens with an -Uvh. I would suggest to copy out the changes you have made before doing an update.

UPDATED 2004-02-11 There was an error in tomcat4 which was pointed out by Marc Gimpel: "I noticed a small error in the init.d/tomcat4 script, on line 135 it reads: "kill -9 $kipd" instead of kill -9 $kpid". This have been updated in the tomcat4 which is available from this site.

  1. Follow My instruction on howto create mod_jk2 as an RPM, as it is required for Jakarta-Tomcat to install
  2. Download Jakarta-Tomcat 4.1.29 (not Tomcat 5), from here: http://jakarta.apache.org/site/binindex.cgi. The current released version is 4.1.29. And save it to your rpmbuild/SOURCES directory.
  3. Then download the following files: And save them to your rpmbuild/SOURCES directory
  4. Then download tomcat4.spec and save it to your rpmbuild/SPECS directory.
  5. Then in your SPECS directory run: rpmbuild -ba tomcat4.spec
    [casper@localhost SPECS]$ rpmbuild -ba tomcat4.spec
    Executing(%prep): /bin/sh -e /home/casper/rpmbuild/TMP/rpm-tmp.88678
    + umask 022
    + cd /home/casper/rpmbuild//BUILD
    + LANG=C
    + export LANG
    + unset DISPLAY
    + rm -rf /home/casper/rpmbuild//BUILD/jakarta-tomcat-4.1.29
    + cd /home/casper/rpmbuild/BUILD
    + rm -rf jakarta-tomcat-4.1.29
    + /usr/bin/gzip -dc /home/casper/rpmbuild/SOURCES/jakarta-tomcat-4.1.29.tar.gz
    .................
    Wrote: /home/casper/rpmbuild/SRPMS/jakarta-tomcat-4.1.29-2.fc1.src.rpm
    Wrote: /home/casper/rpmbuild/RPMS/i386/jakarta-tomcat-4.1.29-2.fc1.i386.rpm
    Wrote: /home/casper/rpmbuild/RPMS/i386/jakarta-tomcat-debuginfo-4.1.29-2.fc1.i386.rpm
    Executing(%clean): /bin/sh -e /home/casper/rpmbuild/TMP/rpm-tmp.40591
    + umask 022
    + cd /home/casper/rpmbuild//BUILD
    + cd jakarta-tomcat-4.1.29
    + rm -rf /home/casper/rpmbuild/TMP/jakarta-tomcat-4.1.29-2.fc1-root-casper+ exit 0
    [casper@localhost SPECS]$
    
  6. Now that you have build the RPM package it's time to install it.
    [casper@localhost SPECS]$ su -c "rpm -ivh jakarta-tomcat-4.1.29-2.fc1.i386.rpm"
    Password: 
    Preparing...                ########################################### [100%]
    Creating "tomcat4" group
    Creating "tomcat4" user
       1:jakarta-tomcat         ########################################### [100%]
    
    If you get an error like this:
    error: Failed dependencies:
            httpd >= 2.0.47 is needed by jakarta-tomcat-4.1.29-2.fc1
            mod_jk2 >= 2.0.2 is needed by jakarta-tomcat-4.1.29-2.fc1
    
    Then you're missing a webserver (Apache2), and mod_jk2, if you're just installing it for testing use:
    [casper@localhost SPECS]$ su -c "rpm -ivh --nodeps jakarta-tomcat-4.1.29-2.fc1.i386.rpm"
    
    To disable dependency checking. Otherwise install Apache2:
    [casper@localhost SPECS]$ su -c "yum install httpd"
    Password:
    ...
    [casper@localhost SPECS]$ 
    
    And mod_jk2.
  7. Now start it:
    [casper@localhost SPECS]$ su -c "/sbin/service tomcat4 start"
    Password:
    Starting tomcat4:                                          [  OK  ]
    [casper@localhost SPECS]$ 
    

  8. So does it work?
    To test it first use the internal webserver of Tomcat: http://localhost:8080, you should see something like this if it works:

    Click on picture for full size

You can find more information about Jakarta-Tomcat (or Tomcat), here: