1.下载Tomcat的tar.gz包(tomcat依赖java环境,如未装JDK需先安装JDK)
curl -O http://mirrors.cnnic.cn/apache/tomcat/tomcat-6/v6.0.41/bin/apache-tomcat-6.0.41.tar.gz
2.解压缩tar.gz
mkdir /usr/local/server tar -zxvf apache-tomcat-6.0.41.tar.gz -C /usr/local/server
3.测试Tomcat运行环境
apache-tomcat-6.0.41/bin/startup.sh
如出现如下字符,则测试成功
Using CATALINA_BASE: /usr/local/server/apache-tomcat-6.0.41 Using CATALINA_HOME: /usr/local/server/apache-tomcat-6.0.41 Using CATALINA_TMPDIR: /usr/local/server/apache-tomcat-6.0.41/temp Using JRE_HOME: /usr Using CLASSPATH: /usr/local/server/apache-tomcat-6.0.41/bin/bootstrap.jar
结束Tomcat进程
ps aux | grep tomcat root 2933 1.3 6.1 1068472 62480 pts/0 Sl 20:20 0:02 /usr/bin/java -Djava.util.logging.config.file=/usr/local/server/apache-tomcat-6.0.41/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/server/apache-tomcat-6.0.41/endorsed -classpath /usr/local/server/apache-tomcat-6.0.41/bin/bootstrap.jar -Dcatalina.base=/usr/local/server/apache-tomcat-6.0.41 -Dcatalina.home=/usr/local/server/apache-tomcat-6.0.41 -Djava.io.tmpdir=/usr/local/server/apache-tomcat-6.0.41/temp org.apache.catalina.startup.Bootstrap start root 2960 0.0 0.0 103240 848 pts/0 S+ 20:23 0:00 grep tomcat kill -9 2933
4.将Tomcat安装为系统服务
cp catalina.sh /etc/init.d/tomcat
编辑tomcat文件
vim /etc/init.d/tomcat
在注释结束部分添加
# OS specific support. $var _must_ be set to either true or false. # 添加以下内容, # chkconfig # 参数1:系统启动级别(这里代表2,3,4,5都自动启动服务) # 参数2:服务启动顺序 # 参数3:服务停止顺序 # description 服务描述 #chkconfig:2345 10 90 #description:Tomcat service
继续添加java,tomcat路径
CATALINA_HOME=/usr/local/server/apache-tomcat-6.0.41 JAVA_HOME=/usr/java/jdk1.6.0_45
编辑完成后:wq退出,并添加服务
chkconfig --add tomcat
查看服务添加是否成功
chkconfig --list | grep tomcat
出现以下字符则添加成功(可以看到Linux 7中运行级别,下标从0开始,2,3,4,5都设为启动)
tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off
5.重启测试
reboot
这时候会有报错,/usr/local/server/apache-tomcat-6.0.41/logs权限不足
chmod 777 /usr/local/server/apache-tomcat-6.0.41/logs
重启...,启动完成
ps aux | grep tomcat
service tomcat stop service tomcat start
本文完
Redhat下Tomcat安装配置
时间: 2025-01-15 16:40:39