TomCat 安装与配置
软件包 :
jdk-6u21-linux-i586-rpm.bin
apache-tomcat- 6.0.28 .tar.gz
下载地址 :
http://java.sun.com/javase/downloads/widget/jdk6.jsp
http://tomcat.apache.org/
 
安装 JDK
[root@station1 src]# chmod u+x jdk-6u21-linux-i586-rpm.bin
[root@station1 src]# ./jdk-6u21-linux-i586-rpm.bin
..Java(TM) SE Development Kit 6 successfully installed.
[root@station1 src]# java --version
java version " 1.4.2 "
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2 -46)
 
Copyright (C) 2006 Free Software Foundation, Inc.
 
[root@station1 src]# rpm -ql jdk   查看 JDK 安装在 /usr/java/jdk 1.6.0 _21
[root@station1 ~]# ln -s /usr/java/jdk 1.6.0 _21/ /usr/java/jdk
 
配置JAVA环境变量
[root@station1 ~]# vim /etc/profile
export JAVA_HOME=/usr/java/jdk
export JRE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
[root@station1 ~]# source /etc/profile
 
安装Tomcat
[root@station1 src]# tar -zxvf apache-tomcat- 6.0.28 .tar.gz -C /usr/local/
[root@station1 src]# cd /usr/local/
[root@station1 local]# mv apache-tomcat- 6.0.28 / apache-tomcat
启动Tomcat
[root@station1 ~]# /usr/local/apache-tomcat/bin/startup.sh
Using CATALINA_BASE:   /usr/local/apache-tomcat
Using CATALINA_HOME:   /usr/local/apache-tomcat
Using CATALINA_TMPDIR: /usr/local/apache-tomcat/temp
Using JRE_HOME:        /usr/java/jdk/jre
Using CLASSPATH:       /usr/local/apache-tomcat/bin/bootstrap.jar
[root@station1 ~]# netstat -antulp | grep 8080
tcp        0      0 :::8080       :::*       LISTEN      8067/java
[root@station1 ~]#
 
再附上Tomcatsystem V 式脚本(在网上某Linux论坛上找的):
#!/bin/bash
# chkconfig: 2345 99 10
# description: Start or stop the Tomcat server
#pidfile: /var/run/tomcat.pid
. /etc/rc.d/init.d/functions
RETVAL=0
prog="Tomcat"
#
设置环境变量 根据实际情况做修改
JAVA_HOME=/opt/j2sdk
CLASSPATH=/opt/j2sdk/lib/tools.jar
CATALINA_HOME=/opt/tomcat5
PID_FILE=/var/run/tomcat.pid
PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:$JAVA_HOME/bin:$CATALINA_HOME/bin
export JAVA_HOME CLASSPATH CATALINA_HOME PATH
start(){
        echo -n "Starting $prog:"
        startup.sh   >;/dev/null
        RETVAL=$?
        [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
        [ $RETVAL = 0 ] && echo_success || echo_failure
        result=`ps -aux|grep  java|awk -F " " '{if ($11!~/grep/) print $2}'`
        if [ ! -z $PID_FILE ] ; then
        echo $result >; $PID_FILE
        fi
        echo
        return $RETVAL
}
stop(){
        echo -n "Stopping $prog:"
        kill -9 `cat $PID_FILE`
        RETVAL=$?
        [ $RETVAL = 0 ] && rm /var/lock/subsys/tomcat
        [ $RETVAL = 0 ] && echo_success || echo_failure
        if [ ! -z $PID_FILE ] ; then
        rm -rf $PID_FILE
        fi
        echo
        return $RETVAL
}
status(){
        result=`ps -aux|grep  java|awk -F " " '{if ($11!~/grep/) print $2}'`
        if [ $result ] ; then
        echo "$prog (pid $result) 
正在运行"
        else
        echo "$prog
已停"
        fi
}
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        status)
                status
                ;;
        restart|reload)
                stop
                start
                ;;
        *)
        echo "Usage:$0 {start|stop|status|restart|reload}"
        RETVAL=1
esac
exit $RETVAL
 
将些脚本放置到/etc/init.d/目录下命名tomcat,给相应执行权限.
#chkconfig --add tomcat 
#chkconfig tomcat on
 
打开测试页面http://localhost:8080
Tomcat精简配置_第1张图片
Tomcat精简配置_第2张图片