1:bin目录,The bin directory contains many scripts,包含启动或关闭tomcat的脚本, windows下是startup.bat和shutdown.bat ,linux下为startup.sh和shutdown.sh ,还有catalina.sh catalina.bat setclasspath.sh setclasspath.sh也较常用
catalina The main Tomcat script. This runs the java command to invoke the Tomcat startup and shutdown classes.
catalina.sh几个常用项:
run This starts up Tomcat without redirecting the standard output and errors. ##启动过程中的日志不进日志
start This starts up Tomcat, with standard output and errors going to the Tomcat logfiles. ##启动过程中输出进日志文件
stop This stops Tomcat.
使用不同见附件:
cpappend This is used internally, and then only on Windows systems, to append items to Tomcat classpath environment variables.
digest This makes a crypto digest of Tomcat passwords. Use it to generate encrypted passwords.
service This script installs and uninstalls Tomcat as a Windows service.
setclasspath This is also only used internally and sets the Tomcat classpath and several other environment variables.
shutdown This runs catalina stop and shuts down Tomcat.
startup This runs catalina start and starts up Tomcat.
2:logs目录,The logs directory is the default location for application log files,tomcat的默认日志目录, tomcat启动失败或项目编译失败,都可以到此目录中去查找原因,我们常用的是catalina.out和localhost--`date`.out两个日志文件
3:temp目录,Tomcat uses the temp directory for storing temporary files.用来存储tomcat的临时文件
4:worker目录,The work directory is where Tomcat places the JSP code after it has been converted into servlet code. Once a JSP page has been visited, Tomcat also stores the compiled servlet here. 显然是用来存储servlet的, 因为jsp的运行,先要编译成servlet。有时候会遇到一个问题:程序修改过后, 但显示的还是以前的结果, 就是这个目录的缘故, 只需要将其清空,下次tomcat运行就会重新编译,问题即可解决
5:lib目录,This directory contains all the various JAR files for Tomcat.包含tomcat用到的jar包。 这个是tomcat6.0才有的。tomcat5.5是有common/lib目录 server/lib 和shared/lib三个lib目录(没有$CATALINA_HOME/lib) , 区别是:commmon/lib中的jar包可以被tomcat和web项目同时加载 ,server/lib 下的jar包只能被tomcat加载,shared/lib下的jar包只能被web 项目加载
6:conf目录, 这个包含了tomcat的各种配置文件
catalina.policy
sets up the necessary permissions for Catalina when it’s run within the context of a security manager
catalina.properties
sets the locations of the various class loader directories. The defaults are the common, server, and shared directories and their subdirectories. The settings in this file determine which classes are available to all web applications and which classes are available to Tomcat. In other words, these settings configure the classpath of Tomcat and all web applications.context of a security manager.
context.xml
is a file that sets the defaults for individual contexts.
logging.properties
is a file that manages the default logging levels for the Tomcat server itself.
server.xml
is the main configuration file for Tomcat You use it to configure everything from the shutdown command to logging,filtering, connections to other web servers, the port and host on which the server is running, and the location of each web application’s files.
tomcat-users.xml
is the default user database for container-managed authentication. You can change the name and location of the file in server.xml.
web.xml
is the default deployment descriptor for all web applications. Tomcat processes
it before processing the
web.xml files in the server’s web applications.
Linux下启动tomcat
1:务必设置JAVA_HOME变量
Echo your $JAVA_HOME environment variable. Make sure it’s set to the absolute path
of the directory where the Java installation you want Tomcat to use resides. If it’s not, set it and export it now. It’s OK if the java interpreter is not on your $PATH because Tomcat’s scripts are smart enough to findanduse Java basedon your setting of $JAVA_HOME.
tomcat是用java写的,故安装tomat时(windows下安装)会提示让定位jdk/jre的位置,没有jdk,tomcat就不能正常运行!
2:tomcat下几个变量的认识:
CATALINA_BASE This sets the base directory for writable or customized portions of a Tomcat installation tree, such as logging files, work directories,
Tomcat’s conf directory, and the webapps directory. It is an alias for CATALINA_HOME. The default value is Tomcat installation directory
CATALINA_HOME This sets the base directory for static (read-only) portions of Tomcat, such as Tomcat’s lib directories and command-line scripts.
The default value is Tomcat installation directory
CATALINA_TMPDIR This sets the directory for Tomcat temporary files. CATALINA_HOME/temp
JAVA_HOME This sets the location of the Java runtime or JDK that Tomcat will use. The default value is None
JRE_HOME This is an alias to JAVA_HOME. The default value is None
JAVA_OPTS This is where you may set any Java command-line options. None
3:通过命令启动tomat
4:设置tomcat开机启动(方法之一)
Example 1-2. A Tomcat init script for Linux
#!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.
JAVA_HOME=/usr/java/jdk1.6.0_02
CATALINA_HOME=/opt/apache-tomcat-6.0.14
export JAVA_HOME CATALINA_HOME
exec $CATALINA_HOME/bin/catalina.sh $*
Save this script in a file named tomcat andchange the file ownership andgroup to
root, and then chmod it to 755:
# chown root.root tomcat
# chmod 755 tomcat
Copy the script to the /etc/rc.d/init.d directory after modifying the JAVA_HOME and
CATALINA_HOME environment variables to fit your system. Then, set the new tomcat
service to start andstop automatically by using chkconfig, as shown earlier in this
section.
5:查询tomcat是否启动(方法之一)?
ps auwwx | grep catalina.startup.Bootstrap
阅读(2085) | 评论(0) | 转发(0) |