注:需要注意的是每个应用程序都有 WEB-INF路径,有时还有META-INF文件,这两个路径下用来放私有资源,是用户通过Web访问URL不能访问到的,除了这两个路径下的资源都可以用web访问URL访问到
为Tomcat提供init脚本
[root@node1 java]# vim /etc/rc.d/init.d/tomcat
#!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.
export JAVA_OPTS='-Xms64m -Xmx128m' #定义启动时堆内存最小64M,最大128M
JAVA_HOME=/usr/local/java/jdk1.8.0_111 #Java的路径
CATALINA_HOME=/usr/local/apache-tomcat-7.0.73 #Tomcat的路径
export JAVA_HOME CATALINA_HOME #将Java和tomcat的路径输出为环境变量
exec $CATALINA_HOME/bin/catalina.sh $* #执行这个脚本
[root@node1 java]# chkconfig --add tomcat #加执行权限
[root@node1 java]# chkconfig --list tomcat #加入系统服务列表
tomcat 0:off1:off2:on3:on4:on5:on6:off
[root@node1 java]# service tomcat stop
Using CATALINA_BASE: /usr/local/apache-tomcat-7.0.73
Using CATALINA_HOME: /usr/local/apache-tomcat-7.0.73
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.73/temp
Using JRE_HOME: /usr/local/java/jdk1.8.0_111
Using CLASSPATH: /usr/local/apache-tomcat-7.0.73/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.73/bin/tomcat-juli.jar
[root@node1 java]# service tomcat start
Using CATALINA_BASE: /usr/local/apache-tomcat-7.0.73
Using CATALINA_HOME: /usr/local/apache-tomcat-7.0.73
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.73/temp
Using JRE_HOME: /usr/local/java/jdk1.8.0_111
Using CLASSPATH: /usr/local/apache-tomcat-7.0.73/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.73/bin/tomcat-juli.jar
Tomcat started.
注:这个脚本不支持restart,但还支持以下许多参数(就是执行了catalina.sh脚本)
[root@node1 java]# service tomcat -help
debug Start Catalina in a debugger
debug -security Debug Catalina with a security manager
jpda start Start Catalina under JPDA debugger
run Start Catalina in the current window
run -security Start in the current window with security manager
start Start Catalina in a separate window
start -security Start in a separate window with security manager
stop Stop Catalina, waiting up to 5 seconds for the process to end
stop n Stop Catalina, waiting up to n seconds for the process to end
stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running
configtest Run a basic syntax check on server.xml - check exit code for result
version What version of tomcat are you running?