linux设置tomcat开机启动

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux设置tomcat开机启动相关的知识,希望对你有一定的参考价值。

[[email protected] ~]# cd /etc/rc.d/
[[email protected] rc.d]# cat rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you dont
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
#./doc/redis-3.0.4/src/redis-server /doc/redis-3.0.4/redis.conf 
export JAVA_HOME=/usr/local/java/jdk1.7.0
/usr/local/tomcat/apache-tomcat-7.0.62/bin/startup.sh start
[[email protected] rc.d]# 
解析rc.local文件

1.配置环境变量
export JAVA_HOME
=/usr/local/java/jdk1.7.0 (JDK的安装目录,可以用$echo $JAVA_HOME获取) 以下是我的服务器寻找JAVA_HOME环境变量的方法 [[email protected] rc.d]# $echo $JAVA_HOME -bash: /usr/local/java/jdk1.7.0: is a directory
2.配置tomcat路径
/usr/local/tomcat/apache-tomcat-7.0.62/bin/startup.sh start
这句话是tomcat的web服务器的startup.sh位置路径 再加上start即可

3.保存文件
按esc然后输入:wq 此刻我们已经保存好rc.local输入的内容了

4.修改rc.local文件为可执行,如:chmod +x rc.local

5.让服务器重启
shutdown -r now

6.开机登录后执行
ps -ef|grep java
看重启后登录是否有java进程 如果有则ok

[[email protected] rc.d]# ps -ef|grep java

root 1102 1 0 16:19 ? 00:00:04 /usr/local/java/jdk1.7.0/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/apache-tomcat-7.0.62/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/apache-tomcat-7.0.62/endorsed -classpath /usr/local/tomcat/apache-tomcat-7.0.62/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-7.0.62/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/apache-tomcat-7.0.62 -Dcatalina.home=/usr/local/tomcat/apache-tomcat-7.0.62 -Djava.io.tmpdir=/usr/local/tomcat/apache-tomcat-7.0.62/temp org.apache.catalina.startup.Bootstrap start start
root 1187 1005 0 16:28 pts/1 00:00:00 grep java




 

以上是关于linux设置tomcat开机启动的主要内容,如果未能解决你的问题,请参考以下文章

Linux学习12-CentOS设置多个tomcat开机自启动

Linux设置tomcat开机自启动

linux设置tomcat开机启动

Linux:Tomcat配置及设置开机自启动

Linux设置tomcat开机自启动:centos7

设置linux开机自动启动Tomcat