linux开启时怎么启动tomcat
1个回答
展开全部
第一步,建立脚本sudo vim /etc/init.d/tomcat
脚本内容如下:
#!/bin/sh
#file:tomcat5.sh
#设置环境变量,如果无法启动就将注释去掉
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export JRE_HOME=/usr/lib/jvm/java-6-sun/jre
export TOMCAT_HOME=/opt/apache-tomcat-5.5.27
export CLASSPATH=.:/usr/lib/jvm/java-6-sun/lib/tools.jar:$JAVA_HOME/bin:$JRE_HOME/bin
export PATH=$JAVA_HOME/lib:$CLASSPATH:$PATH:$TOMCAT_HOME:$JRE_HOME:$JRE_HOME/bin
case "$1" in
start)
echo "starting tomcat5..."
/opt/apache-tomcat-5.5.27/bin/startup.sh
;;
stop)
echo "stopping tomcat5..."
/opt/apache-tomcat-5.5.27/bin/shutdown.sh
;;
*)
echo "usage tomcat.sh start/stop"
exit 1;;
esac
#tomcat5.sh end
第二步,加入相应等级的启动项
sudo chkconfig --level 2345 tomcat on
脚本内容如下:
#!/bin/sh
#file:tomcat5.sh
#设置环境变量,如果无法启动就将注释去掉
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export JRE_HOME=/usr/lib/jvm/java-6-sun/jre
export TOMCAT_HOME=/opt/apache-tomcat-5.5.27
export CLASSPATH=.:/usr/lib/jvm/java-6-sun/lib/tools.jar:$JAVA_HOME/bin:$JRE_HOME/bin
export PATH=$JAVA_HOME/lib:$CLASSPATH:$PATH:$TOMCAT_HOME:$JRE_HOME:$JRE_HOME/bin
case "$1" in
start)
echo "starting tomcat5..."
/opt/apache-tomcat-5.5.27/bin/startup.sh
;;
stop)
echo "stopping tomcat5..."
/opt/apache-tomcat-5.5.27/bin/shutdown.sh
;;
*)
echo "usage tomcat.sh start/stop"
exit 1;;
esac
#tomcat5.sh end
第二步,加入相应等级的启动项
sudo chkconfig --level 2345 tomcat on
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询