CentOS/Linux 下设置 tomcat开机自启动 tomcat
程序员文章站
2024-03-23 09:06:04
...
一、方式一
1.修改Tomcat目录下面的/bin/startup.sh文件:
export JAVA_HOME=/usr/local/JDK7
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export PATH=$PATH:$JAVA_HOME/bin
export CATALINA_HOME=/usr/local/tomcat7_1
/usr/local/tomcat7_1/bin/catalina.sh start
/usr/local/tomcat7_1/bin/catalina.sh start
2.在/etc/rc.d/rc.local中加入:
/usr/local/tomcat7_1/bin/startup.sh
二、方式二
1.新建一个文件 vi tomcat
2.添加下面的命令
#!/bin/bash
#
# starguo guoxin_jy@126.com
# /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_1"
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
3.chmod 755 tomcat 添加可执行权限
#
# starguo guoxin_jy@126.com
# /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_1"
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
3.chmod 755 tomcat 添加可执行权限
4.cp tomcat /etc/init.d/tomcat
5. chkconfig --add tomcat
6.在tomcat目录下面的 bin/catalina.sh文件里面添加
export JAVA_HOME=/usr/local/JDK7
export CATALINA_HOME=/usr/local/tomcat7_1
export CATALINA_BASE=/usr/local/tomcat7_1
export CATALINA_TMPDIR=/usr/local/tomcat7_1/temp
export CATALINA_HOME=/usr/local/tomcat7_1
export CATALINA_BASE=/usr/local/tomcat7_1
export CATALINA_TMPDIR=/usr/local/tomcat7_1/temp
7.service tomcat start/stop
上一篇: Mybatis 07 一对多表关联查询
推荐阅读
-
centOS6.4下安装Tomcat7 博客分类: Linux Tomcatcentos
-
linux下 安装zookeeper,设置开机自启动
-
utuntu上设置Tomcat开机自动启动 博客分类: linux
-
utuntu上设置Tomcat开机自动启动 博客分类: linux
-
【学习笔记 - Linux】CentOS7下安装jdk1.8、tomcat8.5、mysql5.7——搭建java web开发环境
-
Linux下tomcat自启动脚本 博客分类: Linux linuxtomcat部署
-
linux下centos中nginx配置一台服务器多个tomcat,多个域名
-
linux下数据库实例开机自启动设置
-
linux下oracle设置开机自启动实现方法
-
Linux下Redis设置密码及开机自启动