From FreeBSDwiki
Jump to: navigation, search

Tomcat is used as a server to run Java Servlets. It can be used stand alone or through Apache. Java Servlets is a great language which is very flexible. You can perform balance loading and connect to many great database engines such as postgres. There are many frameworks which you can use to speed up development and keep your code organised, a popular framework is 'struts'.

In this document I will explain how to setup jakarta-tomcat-5.5




The packages and version numbers I will be installing/working with here are:

  • FreeBSD 6.1
  • jakarta-tomcat-5.5.17_1
  • jakarta-struts 1.2.4
  • apache-ant-1.6.5_1
  • diablo-jdk-freebsd6.i386.
  • PostgreSQL 8.1.4
  • KATE 2.5.3

    Install Java

    cd /usr/ports/java/diablo-jdk15/ && make install clean Java will require you to download a heap of files separately through the browser and place them in /usr/ports/distfiles

    Install Tomcat

    Install tomcat from ports as the post-install scripts help configure the system faster.

    1. cd /usr/ports/*/tomcat55
    2. make install

    Install ANT

    Used for compiling

    1. pkg_add -r apache-ant


    There is a lot of configuration and tests which you can do in tomcat. Here I'm going to show a basic setup in which you should be able to start some projects.


    If you want all the servers to load up on boot here is what you have to add to /etc/rc.conf


    Setup Environment Variables

    Editing /etc/profile

    JAVA_HOME=/usr/local/diablo-jdk1.5.0; export JAVA_HOME
    CATALINA_HOME="/usr/local/tomcat5.5"; export CATALINA_HOME
    CATALINA_BASE="/usr/local/tomcat5.5"; export CATALINA_BASE
    CATALINA_TMPDIR="/usr/local/tomcat5.5/temp"; export CATALINA_TMPDIR
    /usr/local/tomcat5.5/common/lib/jsp-api.jar:.";export CLASSPATH

    Tomcat Servlet Reloading

    So that your modifications are automatically reloaded on your development box edit: /usr/local/tomcat5.5/conf/context.xml and change:



    <Context reloadable="true">

    First time startup

    To start the tomcat server for the first time here is what you do:

    shell# cd /usr/local/tomcat5.5/bin
    shell# bash
    shell# JAVA_HOME=”/usr/local/diablo-jdk1.5.0”;export JAVA_HOME
    shell# ./

    Using Tomcat

    The default for tomcat is http://<ip>:8180 (used to be on port 8080)

    The work area is /usr/local/tomcat5.5/webapps

    You can enter project_name.war files into the webapps directory then access them like so:

  • Personal tools