Convert Microsoft to LINUX: TOMCAT Java Webserver

TOMCAT Java Web Server comes in many flavors and platforms. I chose the simplest way to install it using the Solaris 10.0 UNIX Server. The default install automatically gives you the Apache server as described here. Note, the Java System Development Kit is already there and everything you need. You just have to do a bit of copying and fine tuning. The Tomcat Server will sit on top of the default Apache server. It uses something called the Jakarta project which provides a module going between the Java TOMCAT sever and the Apache Server which is written in the C programming language. This way if a Java Server Page messes up you still have your plain old Apache Web Server working. Here are the steps:

  1. You need to define the JAVA_HOME directory variable. This is the place where the Java System Development Kit (JSDK) lives. For me it was in the directory of :
    So you would type:
    JAVA_HOME=/usr/jdk/j2sdk1.4.2_11; export JAVA_HOME
    Make sure you are in the bash shell when doing this in case you have to retype anything or use tab completion.To test type:
    echo $JAVA_HOME
    to make sure you did it right.
  2. Next create the following three directories:
    mkdir /usr/apache/tomcat/logs
    mkdir /usr/apache/tomcat/conf
    mkdir /usr/apache/tomcat/webapps
    These are missing from the default install.
  3. Next type
    cd /usr/apache/tomcat/conf
    cp /var/apache/tomcat/conf/* .
    cp server.xml-example server.xml
  4. Next type
    rsync -a /var/apache/tomcat/webapps/ /usr/apache/tomcat/webapps
    to copy the directory from the var branch to the usr branch. If for some reason you do not have this command you can do it with the GUI using the file manager.
  5. Next type:
    cd /usr/apache/tomcat/bin
  6. Let us check all is ok. Type:
    ps -ef | grep tomcat
    to make sure the tomcat daemon is running. You should see:
    root 6657 1 0 18:06:13 pts/3
    10:05 /usr/jdk/j2sdk1.4.2_11/bin/java -Djava.endorsed.dirs=/usr/apache/tomcat/bin:/us
  7. Lastly open a web browser and type:
    You should get the default webpage saying:
    TOMCAT Version 4.05 ... The Jakarta Project..
  8. Now that you are sure everything works you can edit the file so that the first two lines are:
    # Define the JAVA_HOME variable to launch Tomcat
    JAVA_HOME=/usr/jdk/j2sdk1.4.2_11; export JAVA_HOME
  9. Lastly, edit /etc/profile so that Tomcat starts automatically by making the last line:

Tomcat can also run on Centos. Here are the steps:

  1. Go to here and search for Linux Platform - J2SE(TM) Development Kit 5.0 Update 11(as of 3/16/7 most recent Java Development Kit). This automatically includes the JRE (Java Runtime Environment) also. The file will be called "jdk-1_5_0_11-linux-i586-rpm.bin". I like to put it in the directory /usr/local/src. I assume you are logged in as root when you do the download.
  2. mkdir /usr/local/java if it is not already there.
  3. cd /usr/local/src
  4. cp jdk-1_5*.bin /usr/local/java , i.e. what you just downloaded.
  5. cd /usr/local/java
    chmod +x j*.bin so you can execute it.
  6. cd /usr/java
    This is where all your various versions of Jave Runtime Environment and Java Development Kit live.
  7. Create symbolic links for the current version you just installed.
    ln -s jdk1.5.0_11 j2sdk
    ln -s jre1.5.0_11 j2jre
  8. rm *.bin
    You should not need the binaries any more.
  9. Add the following section to the end of your /etc/profile as outlined here. Be sure to make a backup copy before modifying your /etc/profile.
  10. source /etc/profile
    Note, you will probably get an error saying /usr/local/tomcat is not found because you have not installed it yet. That is ok. We will do that next, after checking the Java installed successfully.
  11. Type java -version
    You should see something like: java version "1.5.0_11"
  12. Tomcat will use tcp port 8080. Let us first make sure that is enabled. Go to Application | System Settings | Security Level | Enable Firewall | Other Ports and add in tcp port 8080 and click enable. You may have to stop the service iptables first to do this. Once the service is reenabled you should see a listing to accept tcp port 8080.
  13. We now need to create the user tomcat that will login with no login shell. Type:
    cd /usr/local/src
    groupadd -g 220 tomcat
    useradd -u 220 -g tomcat -c "Tomcat" -r -d /usr/local/tomcat -s "sbin/nologin" tomcat
    Note that last command is all on one line.
  14. To download the source type:
    Yes that was all one line.
    tar xfvz apache-tomcat-5.5.23.tar.gz -C /usr/local
    cd /usr/local
    chown -R tomcat:tomcat /usr/local/apache-tomcat-5.5.23
    ln -s apache-tomcat-5.5.23 tomcat
    The last line creates the symbolic link to tomcat.
  15. Now let us "re-source" the profile:
    source /etc/profile
    This time there should be no errors. Go to
    http://localhost:8080 in your favorite browser and you should see the Tomcat Jakarta 5.5.23 Logo.
  16. For a final touch, so you can click on the Admin Tool for Tomcat, you need to add a user that has admin and manage privileges. In the real world you would do something more secure than this. You can copy this file to /usr/local/tomcat/conf/tomcat-users.xml overwriting your previous one. Make sure you make a backup copy first.