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參數。