Centos installation tomcat setup boot
Install tomcat
Unzip tomcat and you can download the installation package from the official website.
[Root @ template tmp] # wget unzip tmp] # tar-zxvf nginx-1.9.15.tar.gz-C/usr/local/start note here I rename the folder name known as apache-tomcat-7.0.69 tomcat7 [root @ template local] # mv apache-tomcat-7.0.69 tomcat7 [root @ template bin] # cd/usr/local/tomcat7/bin/[root @ template bin] #. /startup. sh close [root @ template bin] #. /shutdown. sh set boot start
Add a script to edit the startup service from oracle installation.
Vim/etc/init. d/tomcat7 # create a new file named tomcat7 by myself #! /Bin/bash # oracle: Start/Stop tomcat7 # chkconfig: 345 90 10 # description: tomcat. JAVA_HOME =/usr/local/jdk1.7.0 _ 79JRE_HOME = $ JAVA_HOME/jre. /etc/rc. d/init. d/functionsLOCKFILE =/var/lock/subsys/tomcat7flagTOMCAT_HOME =/usr/local/tomcat7/TOMCAT_USER = rootcase "$1" in 'start') if [-f $ LOCKFILE]; then echo $0 already running. exit 1 fi echo-n $ "Starting tomcat! "/Usr/local/tomcat7/bin/startup. sh touch $ LOCKFILE; 'stop') if [! -F $ LOCKFILE]; then echo $0 already stopping. exit 1 fi echo-n $ "Stopping tomcat! "/Usr/local/tomcat7/bin/shutdown. sh rm-f $ LOCKFILE; 'restart') $0 stop $0 start; 'status') if [-f $ LOCKFILE]; then echo $0 started. else echo $0 stopped. fi; *) echo "Usage: $0 [start | stop | status]" exit 1 esacexit 0
Modify/etc/init. d/tomcat7 service file permissions [root @ CentOS init. d] # chmod 755/etc/init. d/tomcat7
#chkconfig --add tomcat7
If the script is not written, the solution to service myservice does not support chkconfig may appear.
Add the following two sentences #! /Bin/bash. # Chkconfig: 2345 10 90 # description: myservice ....
Set to boot
If prompted
[root@template sbin]# service tomcat7 stopStopping tomcat! Neither the JAVA_HOME nor the JRE_HOME environment variable is definedAt least one of these environment variable is needed to run this program
Make the following changes in tomcat:
Vim/usr/local/tomcat7/bin/startup. sh Add the following environment variable export JAVA_HOME =/usr/local/jdk1.7.0 _ 79 export CLASSPATH = $ CLASSPATH: $ JAVA_HOME/lib/tools. jar: $ JAVA_HOME/lib/dt. jar :. export PATH = $ PATH: $ JAVA_HOME/binexport CATALINA_HOME =/usr/local/tomcat7
[Root @ CentOS ~] # Chkconfig tomcat7 on Test service tomcat7 start/stop/restart
There is also a simple way to directly add the startup command in the startup file to/etc/rc. d/rc. local:/usr/local/tomcat7/bin/startup. sh