1、在/etc/rc.d/rc.local中加入:
#java environment export JAVA_HOME=/usr/java/jdk1.8.0_161 export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar export PATH=$PATH:${JAVA_HOME}/bin /home/tomcat/apache-tomcat-8.5.29/bin/startup.sh
2、更改rc.local的权限
因为如果是centos7的话,默认是系统自动不执行/etc/rc.d/rc.local,需要更改权限
#!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In constrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot. 翻译: #这个文件是为了兼容性的问题而添加的。 # #强烈建议创建自己的systemd服务或