Monday, August 3, 2009

Setting up Apache Tomcat on CentOS5

This past weekend I decided that I didn't like the performance on my current CentOS5 setup. With that in mind, I set out to re-install and begin, again, to configure from scratch. My whole goal with this server is to eventually have running a: web server, emial server for the family, and local domain for the home network (as opposed to the current workgroup settings.

The re-install of CentOS 5.3 was again a breeze. Although, I didn't get into too many security settings. The thought behind that is that I want to make sure it will work for my needs and then I will tighten it down before publishing any content to the world.

The complicated step was the installation and testing of Apache Tomcat 6.0.20. With that in mind, a short 'how-to' (based upon the below link) is below:

To get started:

1) Files needed:
- JAVA:
- These should be saved/moved to: /root
- jre-6u14-linux-i586.bin
- jdk-6u14-linux-i586.bin
- APACHE TOMCAT:
- These should be saved/moved to: /usr/share
- apache-ant-1.7.1-bin.tar.gz
- apache-tomcat-6.0.20.tar.gz
2) Directorys needed:
- /usr/java
3) Notes:
- If some of the below process 'aren't found by your bash shell, use /sbin/[servicename]


Commands:

Install Java (JDK and JRE):

1) move to the java folder:
# cd /usr/java
2) Install JRE and JDK:
# sh /root/jre-6u14-linux-i586.bin
# sh /root/jdk-6u14-linux-i586.bin
- Verify installation. There should be a jre and jdk file in the /usr/java folder

Install ant and Apache

1) move to share folder:
# cd /usr/share
- Install ant first:
# tar -xzf apache-ant-1.7.1-bin.tar.gz
- install apache tomcat
# tar -xzf apache-tomcat-6.0.18.tar.gz

Enable Ant linkage

# ln -s /usr/share/apache-ant-1.7.1/bin/ant /usr/bin

Configure environmental variable:
- move to folder with catalina.sh
#cd /usr/share/apache-tomcat-6.0.20/bin
- open catalina.sh in your favorite editor (I used vi)
- add as a second line:
- JAVA_HOME=/usr/java/jdk1.6.0_14

Test config

# cd /usr/share/apache-tomcat-6.0.20/bin
# ./startup.sh

Check for error log
# less /usr/share/apache-tomcat-6.0.18/logs/catalina.out

Run the startup file (I may have to edit file location...doing this from memory)
#cd /usr/share/apache-tomcat-6.0.20/bin
# ./startup.sh

A startup script can be found on the below link. This script can be used to cause tomcat to start automatically at system startup. I did test this script on my original install, but opted not to use it this time (remember, I reloaded CentOS to try to clear up performance issues). I should note that the below link uses older versions of java (update 10) and of apache tomcat (6.0.18).

My end result is that my service works as it should, I set up a DynDNS account to test it, and I am now ready to re-build my website and move my domain.

Reference:
http://de0ris.blogspot.com/2008/08/installing-tomcat-6x-on-centos-5.html