Linux上安装tomcat

解压缩

cd /usr/local
tar zxvf apache-tomcat-x.x.x.tar.gz

建立启动脚本

vim /etc/init.d/tomcat
#
# !/bin/bash
# Description:  start or stop the tomcat
# Usage:        tomcat [start|stop|reload|restart]
# Author:       didiao
# Date:         Thu Apr 26, 2007
#
export PATH=PATH:HOME/bin
export BASH_ENV=HOME/.bashrc
export USERNAME="root"

case "1" in
start)
#startup the tomcat
echo -n "tomcat start: "
cd /usr/local/tomcat/bin/
. myconfig.sh
./startup.sh
echo "finished"
;;
stop)
# stop the tomcat
echo -n "tomcat stop:"
ps -ef | grep "java" | grep -v grep | sed 's/ [ ]*/:/g'|cut -d: -f2| kill -9 `cat`
echo "finished"
;;
reload|restart)
0 stop0 start
;;
*)

echo "Usage: tomcat [start|stop|reload|restart]"
exit 1

esac
exit 0
chmod 755 /etc/init.d/tomcat

启动tomcat

service tomcat start | stop | reload | restart

发表评论