Linux下离线源码安装配置Tomcat

1、解压

/usr/local # tar xf jdk1.7.0_79.tar -C /usr/local

/usr/local # mv jdk1.7.0_79/ jdk

/usr/local # cd jdk

/usr/local/jdk # ls

COPYRIGHT    THIRDPARTYLICENSEREADME-JAVAFX.txt  db      lib      src.zip

LICENSE      THIRDPARTYLICENSEREADME.txt        include  man

README.html  bin                                jre      release

 

2、配置环境变量

#vim /etc/profile

JAVA_HOME=/usr/local/jdk

JRE_HOME=/usr/local/jdk/jre

CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib

PATH=$JAVA_HOME/bin:$PATH

export PATH CLASSPATH JAVA_HOME

 

3、环境变量立即生效并验证

# source /etc/profile

# java -version

java version "1.7.0_79"

Java(TM) SE Runtime Environment (build 1.7.0_79-b15)

Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

 

4、解压apache-tomcat

# tar zxf apache-tomcat-6.0.37.tar.gz -C /usr/loca

 

/usr/local # cd tomcat

/usr/local/tomcat # ls

LICENSE  RELEASE-NOTES  bin  lib  temp    work

NOTICE  RUNNING.txt    conf  logs  webapps

 

/usr/local/tomcat/bin # ./startup.sh

Using CATALINA_BASE:  /usr/local/tomcat

Using CATALINA_HOME:  /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/local/jdk

Using CLASSPATH:      /usr/local/tomcat/bin/bootstrap.jar

 

/usr/local/tomcat/bin # ps aux | grep java

root      6753  1.1  3.6 777356 69736 pts/0    Sl  10:59  0:02 /usr/local/jdk/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start

root      6872  0.0  0.0  4520  536 pts/0    S+  11:02  0:00 grep java

linux-svnfile:/usr/local/tomcat/bin # netstat -an | grep 8080

tcp        0      0 :::8080                :::*                    LISTEN

 

5、编写启动脚本

# vi /etc/init.d/tomcat

#!/bin/bash

# chkconfig: 2345 85 15

# vi /etc/init.d/tomcat

# init script for tomcat precesses

 

TOMCAT_HOME="/usr/local/tomcat"

 

case "$1" in

start)

        if [ -f $TOMCAT_HOME/bin/startup.sh ];

          then

            echo $"Starting Tomcat"

            "$TOMCAT_HOME/bin/startup.sh"

        fi

        ;;

stop)

        if [ -f $TOMCAT_HOME/bin/shutdown.sh ]

          then

            echo $"Stopping Tomcat"

            "$TOMCAT_HOME/bin/shutdown.sh"

        fi

        ;;

*)

        echo $"Usage: $0 {start|stop}"

        exit 1

        ;;

esac

 

exit 0

 

6、配置tomcat开机自启动

# chmod +x /etc/init.d/tomcat

 

# chkconfig --add tomcat

insserv: warning: script 'S13ITMAgents1' missing LSB tags and overrides

insserv: warning: script 'tomcat' missing LSB tags and overrides

insserv: warning: script 'tomcat' missing LSB tags and overrides

insserv: Default-Start undefined, assuming default start runlevel(s) for script `tomcat'

insserv: warning: script 'ITMAgents1' missing LSB tags and overrides

insserv: Service network is missed in the runlevels 4 to use service ctrmc

insserv: Service syslog is missed in the runlevels 4 to use service ctrmc

tomcat                    0:off  1:off  2:off  3:on  4:off  5:on  6:off

 

# chkconfig tomcat off

insserv: warning: script 'S13ITMAgents1' missing LSB tags and overrides

insserv: warning: script 'S01tomcat' missing LSB tags and overrides

insserv: warning: script 'tomcat' missing LSB tags and overrides

insserv: warning: script 'tomcat' missing LSB tags and overrides

insserv: warning: script 'ITMAgents1' missing LSB tags and overrides

linux-svnfile:/home/apps # chkconfig --list tomcat

tomcat                    0:off  1:off  2:off  3:off  4:off  5:off  6:off

 

# chkconfig tomcat on

insserv: warning: script 'S13ITMAgents1' missing LSB tags and overrides

insserv: warning: script 'tomcat' missing LSB tags and overrides

insserv: warning: script 'tomcat' missing LSB tags and overrides

insserv: Default-Start undefined, assuming default start runlevel(s) for script `tomcat'

insserv: warning: script 'ITMAgents1' missing LSB tags and overrides

insserv: Service network is missed in the runlevels 4 to use service ctrmc

insserv: Service syslog is missed in the runlevels 4 to use service ctrmc

linux-svnfile:/home/apps # chkconfig --list tomcat

tomcat                    0:off  1:off  2:off  3:on  4:off  5:on  6:off

 

# ps aux | grep java

root      7416 17.8  3.4 711288 67208 pts/1    Sl  11:19  0:01 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start

root      7442  0.0  0.0  4520  540 pts/1    S+  11:19  0:00 grep java

linux-svnfile:/home/apps # service tomcat stop

Stopping Tomcat

Using CATALINA_BASE:  /usr/local/tomcat

Using CATALINA_HOME:  /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr

Using CLASSPATH:      /usr/local/tomcat/bin/bootstrap.jar

 

# ps aux | grep java

root      7480  0.0  0.0  4520  540 pts/1    S+  11:19  0:00 grep java

更多Tomcat相关教程见以下内容

Tomcat 的详细介绍:请点这里
Tomcat 的下载地址:请点这里

相关推荐