JavaCollection
JavaCollection copied to clipboard
「软件安装手册」Tomcat配置快捷操作问题
羊哥您好~作为小白首先十分十分感谢您出的软件安装文档,我在实践安装Tomcat中遇到了这个问题:
根据您P38页的教程,进⼊ /etc/rc.d/init.d ⽬录,编辑tomcat文件,保存后尝试使用快捷方式service tomcat start
运行出现了如下bug提示:
[leslie@localhost ~]$ service tomcat start Password: Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program
经过相关查阅,发现是tomcat文件内缺少JAVA_HOME 与 JRE_HOME 环境变量的设置,完整tomcat文件配置代码如下:
#chkconfig:- 20 90
#description:tomcat
#processname:tomcat
export JAVA_HOME="=/usr/local/java/jdk1.8.0_161"
export JRE_HOME="=/usr/local/java/jdk1.8.0_161/jre"
TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-8.5.55
case $1 in
start) su root $TOMCAT_HOME/bin/startup.sh;;
stop) su root $TOMCAT_HOME/bin/shutdown.sh;;
*) echo "require start|stop" ;;
esac
之后便能通过快捷指令service tomcat start
进行tomcat启动了,最后再次感谢您的无私分享!
应该是jdk环境变量没配置吧,JAVA_HOME写死到启动脚本里当然也是可以的
[root@localhost init.d]# cat tomcat
#!/bin/bash
#chkconfig:- 20 90
#description:tomcat
#processname:tomcat
TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-8.5.55
case $1 in
start) su root $TOMCAT_HOME/bin/startup.sh;;
stop) su root $TOMCAT_HOME/bin/shutdown.sh;;
*) echo "require start|stop" ;;
esac
[root@localhost init.d]#
[root@localhost init.d]# java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
[root@localhost init.d]#
[root@localhost init.d]# service tomcat shutdown
require start|stop
[root@localhost init.d]# service tomcat start
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-8.5.55
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-8.5.55
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-8.5.55/temp
Using JRE_HOME: /usr/local/java/jdk1.8.0_161
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-8.5.55/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-8.5.55/bin/tomcat-juli.jar
Tomcat started.
[root@localhost init.d]#