你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux下离线源码安装配置Tomcat

[日期:2017-03-06] 来源:Linux社区  作者:xiaoxiaozhou [字体: ]

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相关教程见以下内容

CentOS 6.6下安装配置Tomcat环境  http://www.linuxidc.com/Linux/2015-08/122234.htm

RedHat Linux 5.5安装JDK+Tomcat并部署Java项目  http://www.linuxidc.com/Linux/2015-02/113528.htm 

Tomcat权威指南(第二版)(中英高清PDF版+带书签)  http://www.linuxidc.com/Linux/2015-02/113062.htm 

Tomcat 安全配置与性能优化 http://www.linuxidc.com/Linux/2015-02/113060.htm 

Linux下使用Xshell查看Tomcat实时日志中文乱码解决方案 http://www.linuxidc.com/Linux/2015-01/112395.htm 

CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤 http://www.linuxidc.com/Linux/2015-01/111485.htm 

CentOS 6.5下安装Tomcat  http://www.linuxidc.com/Linux/2015-01/111415.htm 

Tomcat中session的管理机制  http://www.linuxidc.com/Linux/2016-09/135072.htm

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

本文永久更新链接地址http://www.linuxidc.com/Linux/2017-03/141429.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款