共计 5216 个字符,预计需要花费 14 分钟才能阅读完成。
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
![post-qrcode](https://www.xgss.net/wp-content/uploads/2023/07/二维码-微信公众号256x256.jpg)