By default, RedHat Linux AS and AS4 servers don’t come with a JDK (Java Development Kit) installed on them. Depending on your install, if you run the java command you may get some sort of error message or a file not found message.
chmod 755 jdk-6u2-linux-i586-rpm.bin
./jdk-6u2-linux-i586-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-6u2-linux-i586.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
Done.
JAVA_HOME=/usr/java/default; export JAVA_HOME PATH=$JAVA_HOME/bin:$PATH; export PATH
java -version
And your output should look like:
java version "1.6.0_02" Java(TM) SE Runtime Environment (build 1.6.0_02-b06) Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode, sharing)
mkdir /usr/local/tomcat/
mv apache-tomcat-6.0.14.tar.gz /usr/local/tomcat/
cd /usr/local/tomcat
tar -zxvf apache-tomcat-6.0.14.tar.gz
rm apache-tomcat-6.0.14.tar.gz
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program
Since my JDK is installed in the directory /usr/java/default, I have the following set in my /etc/profile file to always set the JAVA_HOME variable and to put the Java binaries into my PATH:
JAVA_HOME=/usr/java/default; export JAVA_HOME PATH=$JAVA_HOME/bin:$PATH; export PATH
cd /usr/local/tomcat/apache-tomcat-6.0.14/bin ./startup.sh
Your output should look like:
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-6.0.14 Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-6.0.14 Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-6.0.14/temp Using JRE_HOME: /usr/java/default
And doing a ps -aef | grep tomcat should show a Tomcat process running.
http://192.168.1.50:8080
And like magic, the default Tomcat page showed up in my web browser. The IP address or hostname will most likely be different than the one I specified above.
./shutdown.sh
cd /usr/local/tomcat ln -sf apache-tomcat-6.0.14 current
I use these symbolic links in the startup and shutdown scripts that I reference below.
In order to start Tomcat automatically when my server boots up, I setup a script in /etc/init.d. Follow the instructions below to do the same.
vi /etc/init.d/tomcat
…and place the following script in it:
#!/bin/bash
#
# Startup script for Tomcat
#
# chkconfig: - 86 15
# description: Tomcat is a JSP server.
# processname: tomcat
JAVA_HOME=/usr/java/default
export JAVA_HOME
tomcat_home=/usr/local/tomcat/current/bin
start_tomcat=/usr/local/tomcat/current/bin/startup.sh
stop_tomcat=/usr/local/tomcat/current/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."
}
# See how we were called
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
chmod 755 /etc/init.d/tomcat
chkconfig --add tomcat
chkconfig --level 35 tomcat on
chkconfig --list tomcat
And your output should look like the following:
tomcat 0:off 1:off 2:off 3:on 4:off 5:on 6:off
/etc/init.d/tomcat start /etc/init.d/tomcat stop
Furthermore, you should be able to reboot your system and ensure Tomcat starts automatically.