2011年(15)
分类: LINUX
2011-06-07 10:13:05
1.安装JDK( 下载最新版本)
下载jdk-6u10-linux-i586.bin。
然后安装jdk。
# ./jdk-6u10-linux-i586.bin
# mv jdk1.6.0_10 /usr/local/
# cd /usr/local
# ln -s jdk1.6.0_10 jdk6
2.安装Tomcat6
下载apache-tomcat-6.0.18.tar.gz。
# cp apache-tomcat-6.0.18.tar.gz /usr/local/
# cd /usr/local
# tar xzvf apache-tomcat-6.0.18.tar.gz
# ln -s apache-tomcat-6.0.18 tomcat6
3.配置jdk和tomcat的环境变量 ( 下载最新版本)
# vi /etc/profile
编辑环境变量文件,添加如下语句到文件文尾:
export JAVA_HOME=/usr/local/jdk6
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
export TOMCAT_HOME=/usr/local/tomcat6
export CATALINA_HOME=/usr/local/tomcat6
export CLASSPATH=$CLASSPATH:$CATALINA_HOME/common/lib
使环境变量立即生效(最好还是重启一下):
# source /etc/profile
4.启动tomcat
首先为Tomcat编辑一段启动脚本,并置于/etc/rc.d/init.d目录下。
# vi /etc/rc.d/init.d/tomcat
贴入如下内容:
#!/bin/bash
#
# Startup script for the tomcat
#
# chkconfig: 345 80 15
# description: Tomcat is a Servlet+JSP Engine.
export JAVA_HOME=/usr/local/jdk6
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
export TOMCAT_HOME=/usr/local/tomcat6
export CATALINA_HOME=/usr/local/tomcat6
export CLASSPATH=$CLASSPATH:$CATALINA_HOME/common/lib
# Source function library.
. /etc/rc.d/init.d/functions
start(){
if [ -z $(/sbin/pidof java) ]; then
echo "Starting tomcat6"
/usr/local/tomcat6/bin/startup.sh
touch /var/lock/subsys/tomcat
else
echo "tomcat allready running"
fi
}
stop(){
if [ ! -z $(/sbin/pidof java) ]; then
echo "Shutting down tomcat"
/usr/local/tomcat6/bin/shutdown.sh
until [ -z $(/sbin/pidof java) ]; do :; done
rm -f /var/lock/subsys/tomcat
else
echo "tomcat not running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
/usr/local/tomcat6/bin/catalina.sh version
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
exit 0
让Tomcat作为一项系统服务,并随系统自动启动。
# chmod 755 /etc/rc.d/init.d/tomcat
# chkconfig --add tomcat
# chkconfig tomcat on
# chkconfig --list tomcat
# /etc/rc.d/init.d/tomcat start
打开FF,输入,看到那只猫出来就安装成功。