There are several ways to set up Tomcat for running on different platforms. The main documentation for this is a file called RUNNING.txt. We encourage you to refer to that file if the information below does not answer some of your questions.html
有几种方法能够将Tomcat设置为在不一样平台上运行。这方面的主要文档是一个名为RUNNING.txt的文件 。若是如下信息没法回答您的一些问题,咱们建议您参考该文件。java
Installing Tomcat on Windows can be done easily using the Windows installer. Its interface and functionality is similar to other wizard based installers, with only a few items of interest.web
使用Windows安装程序能够轻松地在Windows上安装Tomcat。它的界面和功能相似于其余基于向导的安装程序,只有几项须要注意的。apache
name=value
在单独的行上使用每对的格式 。可用配置选项的名称是:
...
along with /S and /D=
it is possible to perform fully configured unattended installs of Apache Tomcat. 经过/C=...
一块儿使用/S, /D=
能够执行Apache Tomcat的彻底配置的无人参与安装。The installer will create shortcuts allowing starting and configuring Tomcat. It is important to note that the Tomcat administration web application can only be used when Tomcat is running.bootstrap
安装程序将建立容许启动和配置Tomcat的快捷方式。请务必注意,Tomcat管理Web应用程序只能在Tomcat运行时使用。windows
Tomcat can be run as a daemon using the jsvc tool from the commons-daemon project. Source tarballs for jsvc are included with the Tomcat binaries, and need to be compiled. Building jsvc requires a C ANSI compiler (such as GCC), GNU Autoconf, and a JDK.tomcat
能够使用commons-daemon项目中的jsvc工具将Tomcat做为守护程序运行。jsvc的源代码压缩包包含在Tomcat二进制文件中,须要编译。构建jsvc须要C ANSI编译器(例如GCC),GNU Autoconf和JDK。安全
Before running the script, the JAVA_HOME environment variable should be set to the base path of the JDK. Alternately, when calling the ./configure script, the path of the JDK may be specified using the --with-java parameter, such as ./configure --with-java=/usr/java.bash
在运行脚本以前,JAVA_HOME应将环境变量设置为JDK的基本路径。或者,在调用./configure脚本时,能够使用--with-java参数指定JDK的路径,例如 ./configure --with-java=/usr/java。服务器
Using the following commands should result in a compiled jsvc binary, located in the $CATALINA_HOME/bin folder. This assumes that GNU TAR is used, and that CATALINA_HOME is an environment variable pointing to the base path of the Tomcat installation.
使用如下命令应该会生成位于该$CATALINA_HOME/bin文件夹中的已编译的jsvc二进制文件。这假设使用了GNU TAR,这CATALINA_HOME是一个指向Tomcat安装基本路径的环境变量。
Please note that you should use the GNU make (gmake) instead of the native BSD make on FreeBSD systems.
请注意,您应该在FreeBSD系统上使用GNU make(gmake)而不是本机BSD make。
cd $CATALINA_HOME/bin tar xvfz commons-daemon-native.tar.gz cd commons-daemon-1.1.x-native-src/unix ./configure make cp jsvc ../.. cd ../..
Tomcat can then be run as a daemon using the following commands.
而后能够使用如下命令将Tomcat做为守护程序运行。
CATALINA_BASE=$CATALINA_HOME cd $CATALINA_HOME ./bin/jsvc \ -classpath $CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/tomcat-juli.jar \ -outfile $CATALINA_BASE/logs/catalina.out \ -errfile $CATALINA_BASE/logs/catalina.err \ -Dcatalina.home=$CATALINA_HOME \ -Dcatalina.base=$CATALINA_BASE \ -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \ -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties \ org.apache.catalina.startup.Bootstrap
When running on Java 9 you will need to additionally specify the following when starting jsvc to avoid warnings on shutdown.
在Java 9上运行时,您须要在启动jsvc时另外指定如下内容以免在关闭时发出警告。
... --add-opens=java.base/java.lang=ALL-UNNAMED \ --add-opens=java.base/java.io=ALL-UNNAMED \ --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED \ ...
You may also need to specify -jvm server if the JVM defaults to using a server VM rather than a client VM. This has been observed on OSX.
您可能还须要指定-jvm serverJVM是否默认使用服务器VM而不是客户端VM。这已在OSX上观察到。
jsvc has other useful parameters, such as -user which causes it to switch to another user after the daemon initialization is complete. This allows, for example, running Tomcat as a non privileged user while still being able to use privileged ports. Note that if you use this option and start Tomcat as root, you'll need to disable the org.apache.catalina.security.SecurityListener check that prevents Tomcat starting when running as root.
jsvc还有其余有用的参数,例如 -user 在守护进程初始化完成后它会切换到另外一个用户。例如,这容许将Tomcat做为非特权用户运行,同时仍然能够使用特权端口。请注意,若是您使用此选项并以root身份启动Tomcat,则须要禁用org.apache.catalina.security.SecurityListener以root身份运行时阻止Tomcat启动的 检查。
jsvc --help will return the full jsvc usage information. In particular, the -debug option is useful to debug issues running jsvc.
jsvc --help将返回完整的jsvc使用信息。特别是,该-debug选项对于调试运行jsvc的问题颇有用。
The file $CATALINA_HOME/bin/daemon.sh can be used as a template for starting Tomcat automatically at boot time from /etc/init.d with jsvc.
该文件$CATALINA_HOME/bin/daemon.sh可用做模板,以便在启动时/etc/init.d使用jsvc 自动启动Tomcat 。
Note that the Commons-Daemon JAR file must be on your runtime classpath to run Tomcat in this manner. The Commons-Daemon JAR file is in the Class-Path entry of the bootstrap.jar manifest, but if you get a ClassNotFoundException or a NoClassDefFoundError for a Commons-Daemon class, add the Commons-Daemon JAR to the -cp argument when launching jsvc.
请注意,Commons-Daemon JAR文件必须位于运行时类路径上才能以这种方式运行Tomcat。Commons-Daemon JAR文件位于bootstrap.jar清单的Class-Path条目中,但若是您得到Commons-Daemon类的ClassNotFoundException或NoClassDefFoundError,则在启动jsvc时将Commons-Daemon JAR添加到-cp参数。