8.26.2008

Installing Tomcat 6.x on CentOS 5


UPDATE: This post was revised to work with java6u10 and now includes instructions for automated startup config.
FYI: if you used this post before 11/06, there have been some major changes to the start up script. This new version is the most basic and easiest. ty.

This is a quick and dirty guide for installing Apache Tomcat 6.0.18 on CentOS5. It is based on detailed instructions for CentOS 4 and tomcat 6.0.13 here. If you get no luck, please check out this link for comprehensive explanation and adopt it to your platform.
Install pre-requisite
1. Download java JDK 6 Update 10 and Java Runtime Environment (JRE) 6 Update 10 bin (NOT RPM)

2. Open terminal, su to root and move downloaded files to /root directory
$ su root
Password:
# mv [.....]
3. Create java environment
# mkdir /usr/java
# cd /usr/java
4. Execute downloaded jdk and jre bins.
# sh /root/jre-6u10-linux-i586.bin
# sh /root/jdk-6u10-linux-i586.bin
5. verify install
# ls
you should see that your /usr/java directory now contains jdk1.6.0_10 and jre1.6.0_10 directories
Install overview
1. Download and extract Apache Ant (apache-ant-1.7.1-bin.tar.gz) to /usr/share
# cd /usr/share
# tar -xzf apache-ant-1.7.1-bin.tar.gz
2. Download and extract Apache Tomcat (apache-tomcat-6.0.18.tar.gz) to /usr/share
# tar -xzf apache-tomcat-6.0.18.tar.gz
3. Enable ant link
# ln -s /usr/share/apache-ant-1.7.1/bin/ant /usr/bin
4. Set up JAVA_HOME $env in catalina.sh
# cd /usr/share/apache-tomcat-6.0.18/bin
# vi catalina.sh
5. After the first line, add following
JAVA_HOME=/usr/java/jdk1.6.0_10
6. Test config with Tomcat
# cd /usr/share/apache-tomcat-6.0.18/bin
# ./startup.sh
7. Check logs for errors
# less /usr/share/apache-tomcat-6.0.18/logs/catalina.out
8. Fix errors if any. Go to http://localhost:8080 for Tomcat's web interface.
Automate start up
1. Create script in /etc/init.d for automated start up/shutdown
# cd /etc/init.d
# vi tomcat

2. Place following in the file
#!/bin/bash
# chkconfig: 234 20 80
# description: Tomcat Server basic start/shutdown script
# processname: tomcat
JAVA_HOME=/usr/java/jdk1.6.0_10
export JAVA_HOME
TOMCAT_HOME=/usr/share/apache-tomcat-6.0.18/bin
START_TOMCAT=/usr/share/apache-tomcat-6.0.18/bin/startup.sh
STOP_TOMCAT=/usr/share/apache-tomcat-6.0.18/bin/shutdown.sh
start() {
echo -n "Starting tomcat: "
cd $TOMCAT_HOME
${START_TOMCAT}
echo "done."
}
stop() {
echo -n "Shutting down tomcat: "
cd $TOMCAT_HOME
${STOP_TOMCAT}
echo "done."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0

2. Change permissions
# chmod 755 tomcat
3. Add script to system services
# chkconfig --add tomcat
4. Verify modifications (this script uses levels 2-4)
# chkconfig --level 234 tomcat on
# chkconfig --list tomcat
you should see that service using levels 2, 3 and 4:
tomcat 0:off 1:off 2:on 3:on 4:on 5:off 6:off
5. Test script start up/shutdown
# service tomcat start
# service tomcat stop
So, at this point, tomcat service will start automatically upon reboot. G'luck (:

8.25.2008

Installing Java (Sun JDK 1.6.0) on CentOS 5

This is a quick and dirty guide to installing java on CentOS5.

NOTE: do not log in as root to perform this installation, but you will need credentials with su command. During install, substitute 'user_name' with your login handle.



STEP I: SYS PREP
1. Open terminal

2. Set up working directories (in this example it's ~/rpmbuild)

$ mkdir -p ~/rpmbuild/{SOURCES,SRPMS,SPECS,RPMS,tmp,BUILD}

3. Create ~/.rpmmacros

$ echo "%_topdir /home/user_name/rpmbuild" >> .rpmmacros
$ echo "%_tmppath %{_topdir}/tmp" >> .rpmmacros

4. Log in as root and use YUM to install following packages
$ su root
Password:
# yum install -y rpm-build gcc gcc-c++ redhat-rpm-config
# yum -y install jpackage-utils
# su user_name
$



STEP II: INSTALL JAVA

1. Download JDK 1.6 update 7 self-extracting RPM version (jdk-6u7-linux-i586.bin) from Sun to ~/rpmbuild/SOURCES/

2. Download and build java-1.6.0-sun-1.6.0.7-1jpp.nosrc.rpm package
$ cd ~/rpmbuild
$ curl -L -O http://mirrors.dotsrc.org/jpackage/1.7/generic/SRPMS.non-free/java-1.6.0-sun-1.6.0.7-1jpp.nosrc.rpm
$ rpmbuild --rebuild java-1.6.0-sun-1.6.0.7-1jpp.nosrc.rpm
don't get freaked out by the errors or that it could take a little while, it's ok. Verify that RPMS directory in rpmbuild contains i586 directory with rpms.

3. su to root and migrate rpms to local yum repository

# yum localinstall ~user_name/rpmbuild/RPMS/i586/java-1.6.0-sun-1.6.0.7-1jpp.i586.rpm
NOTE: if you get "NOT SIGNED" issue (and most likely you will), resolve by the following work-around
- install X11 library to resolve libXP.so.6 dependency
# yum install libXp-devel.i386
- then plain old rpm
# rpm -Uvh ~user_name/rpmbuild/RPMS/i586/java-1.6.0-sun-1.6.0.7-1jpp.i586.rpm

4. Login as root to configure alternatives system to use new JDK
[root@blah]# alternatives --config java

5. Verify install
$ java -version
it should display java version "1.6.0_07 ....."

8.13.2008

A gift of a gift makes a perfect... gift

Whether it be a birthday, wedding or a holiday, gifting can present itself to be a serious dilemma. In some ways, it is a formality or an obligation, but also challenges creativity. Below are some ideas on how to get that perfect little something in lieu of a traditional gift.

My favorite source for all my gifts is globalgiving.org network. The company itself is admirable as their objective is to put collected donations to a good use, whether it be helping a community in crisis or having a positive effect on a challenged economy of the country in whole. No project is too big or small, and the best part is GlobalGiving gift card is 100% biodegradable. 100% tax-deductible. 100% guaranteed. Chances are they have a project that is a perfect fit. It can be selected either via topic (such as disaster recovery, health, environment, etc). Or simply search for a cause by the region. Even project selection wizard is available to allow you to make the most fitting choice.

Justgive.org is another creative way to find a perfect gift. Their directory serves as a hub for reputable donation organizations. The company offers a tad stronger focus on domestic and local charities and non-profit organizations, which allows for a more comprehensive selection of a project in your area.

Heifer International has a program that is catching attention world wide. As a donor you can extend your support, but not in a traditional way that one would expect. In their effort to fight hunger and poverty as well as improve the environment, the company provides actual live stock and resources to improve life style in the challenged areas. Their catalog includes items such as heifer, chicks, trees and honeybees.

I've used these companies in a past and gift recipients have always been both: surprised and pleased. Most important, it empowered us both to make a difference in the world. There are many other charity/donation hubs available with similar services, but I thought that I would highlight these three. Also, giving works both ways, and these portals can be used to create wish lists for yourself or those that you know.

Meaningful giving does not always translate to the gift certificates. For example, you can purchase a Christmas tree in a pot and replant it after the holidays. Planting a tree for an event or a person or simply supporting volunteering project in their honor will also be much appreciated.

Happy giving.