注:命令前的#表示root用户,$表示普通用户
安装Tomcat6.0
1、 下载
官网下载tomcat6.tar.gz
http://tomcat.apache.org/download-60.cgi
2、 解包
# tar -zxvf tomcat6.tar.gz -C /usr/local/
3、 启动
./usr/local/ apache-tomcat-6.0.35/startup.sh
4、 添加环境变量
写到/etc/profile中, 添加:
export CATALINA_HOME=/usr/local/apache-tomcat-6.0.35
5、 编写shell脚本,保存为tomcat
#!/bin/bash
#
# Init file for Apache Tomca6 server daemon
#
# chkconfig:235 80 30
#
# description:this is Apache Tomcat6 server daemon
#
# processname:tomcat6
#
# set JAVA_HOME
export JAVA_HOME=/usr/local/jdk1.6.0_37
#set Apache Tomcat6 server path
tomcat6path=/usr/local/apache-tomcat-6.0.35
start()
{
echo -n"start tomcat..."
$tomcat6path/bin/catalina.sh start
}
stop()
{
echo -n"stop tomcat..."
$tomcat6path/bin/catalina.sh stop
}
#do command
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo"Use :$0 {start|stop|restart}"
;;
esac
exit $RETVAL
6、 随机启动
上传tomcat启动脚本到/etc/sysconfig
chmod +x tomcat
#chkconfig --addtomcat
#chkconfig--level 345 tomcat on
#chkconfig --listtomcat