共计 2854 个字符,预计需要花费 8 分钟才能阅读完成。
准备文件如下:
1.CentOS-6.4-x86_64-bin-DVD1.iso
2.jdk-7u67-linux-x64.rpm
3.apache-tomcat-7.0.55.tar.gz
安装步骤如下:
一、安装 JDK
[root@n1 /]# java -version
bash: java: command not found
[root@n1 /]# rpm -ivh /soft/jdk-7u67-linux-x64.rpm
Preparing… ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files…
rt.jar…
jsse.jar…
charsets.jar…
tools.jar…
localedata.jar…
jfxrt.jar…
[root@n1 /]#
[root@n1 /]# java -version
java version “1.7.0_67”
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
[root@n1 /]# cd /usr/java
[root@n1 java]# ls
default jdk1.7.0_67 latest
[root@n1 java]#
二、安装 Tomcat
rm -rf /usr/local/tomcat7
cd /usr
cd /usr/local/tomcat7
ls
ls
cd /
tar zxvf /soft/apache-tomcat-7.0.55.tar.gz
mv /apache-tomcat-7.0.55 /usr/local/tomcat7
chmod +x /usr/local/tomcat7
三、设置环境变量
执行 vim /etc/profile 命令,添加环境变量代码如下
#jdk config
export JAVA_HOME=/usr/java/jdk1.7.0_67
export CALSSPATH=$JAVA_HOME/lib/*.*
#tomcat config
export TOMCAT_HOME=/usr/local/tomcat7
export CATALINA_HOME=/usr/local/tomcat7
#path config
export PATH=$PATH:$JAVA_HOME/bin:$TOMCAT_HOME/bin
执行指令 source /etc/profile 刷新环境变量
四、启动 Tomcat
sh /usr/local/tomcat7/bin/startup.sh
在火狐浏览器中打开网址 http://localhost:8080 测试
关闭 Tomcat 命令
sh /usr/local/tomcat7/bin/shutdown.sh
五、开机启动 Tomcat 脚本
5.1、执行指令 vi /etc/rc.d/init.d/tomcat 生成脚本文件,内容如下
#!/bin/bash
#
# /etc/rc.d/init.d/tomcat
# init script for tomcat precesses
#
# processname: tomcat
# description: tomcat is a j2se server
# chkconfig: 2345 86 16
# description: Start up the Tomcat servlet engine.
if [-f /etc/init.d/functions]; then
. /etc/init.d/functions
elif [-f /etc/rc.d/init.d/functions]; then
. /etc/rc.d/init.d/functions
else
echo -e “\atomcat: unable to locate functions lib. Cannot continue.”
exit -1
fi
RETVAL=$?
CATALINA_HOME=”/usr/local/tomcat7″ #tomcat 安装目录
case “$1” in
start)
if [-f $CATALINA_HOME/bin/startup.sh];
then
echo $”Starting Tomcat”
$CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [-f $CATALINA_HOME/bin/shutdown.sh];
then
echo $”Stopping Tomcat”
$CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $”Usage: $0 {start|stop}”
exit 1
;;
esac
exit $RETVAL
5.2、添加权限 chmod 755 /etc/rc.d/init.d/tomcat,使得脚本文件可执行
5.3、运行:chkconfig –add /etc/rc.d/init.d/tomcat #将其加到服务中
5.4、在 vim /usr/local/tomcat7/bin/catalina.sh 文件中加入以下语句:
#auto startup tomcat config
export JAVA_HOME=/usr/java/jdk1.7.0_67
export CATALINA_HOME=/usr/local/tomcat7
export CATALINA_BASE=/usr/local/tomcat7
export CATALINA_TMPDIR=/usr/local/tomcat7/temp
启动 tomcat 服务:service tomcat start
停止 tomcat 服务: service tomcat stop
Linux 下 Apache 与多个 Tomcat 集群负载均衡 http://www.linuxidc.com/Linux/2012-01/51731.htm
Nginx Tomcat 集群负载均衡解决笔记 http://www.linuxidc.com/Linux/2013-07/86827.htm
实例详解 Tomcat 组件安装 +Nginx 反向代理 Tomcat+Apache 使用 mod_jk 和 mod_proxy 反向代理和负载均衡 http://www.linuxidc.com/Linux/2013-06/85290.htm
CentOS 6.5 下利用 Rsyslog+LogAnalyzer+MySQL 部署日志服务器 http://www.linuxidc.com/Linux/2014-06/103836.htm
Apache+Tomcat 环境搭建(JK 部署过程)http://www.linuxidc.com/Linux/2012-11/74474.htm
Tomcat 的详细介绍 :请点这里
Tomcat 的下载地址 :请点这里