RUNNING.txt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. ================================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ================================================================================
  15. ===================================================
  16. Running The Apache Tomcat 8.5 Servlet/JSP Container
  17. ===================================================
  18. Apache Tomcat 8.5 requires a Java Standard Edition Runtime
  19. Environment (JRE) version 7 or later.
  20. =============================
  21. Running With JRE 7 Or Later
  22. =============================
  23. (1) Download and Install a Java SE Runtime Environment (JRE)
  24. (1.1) Download a Java SE Runtime Environment (JRE),
  25. release version 7 or later, from
  26. http://www.oracle.com/technetwork/java/javase/downloads/index.html
  27. (1.2) Install the JRE according to the instructions included with the
  28. release.
  29. You may also use a full Java Development Kit (JDK) rather than just
  30. a JRE.
  31. (2) Download and Install Apache Tomcat
  32. (2.1) Download a binary distribution of Tomcat from:
  33. https://tomcat.apache.org/
  34. (2.2) Unpack the binary distribution so that it resides in its own
  35. directory (conventionally named "apache-tomcat-[version]").
  36. For the purposes of the remainder of this document, the name
  37. "CATALINA_HOME" is used to refer to the full pathname of that
  38. directory.
  39. NOTE: As an alternative to downloading a binary distribution, you can
  40. create your own from the Tomcat source code, as described in
  41. "BUILDING.txt". You can either
  42. a) Do the full "release" build and find the created distribution in the
  43. "output/release" directory and then proceed with unpacking as above, or
  44. b) Do a simple build and use the "output/build" directory as
  45. "CATALINA_HOME". Be warned that there are some differences between the
  46. contents of the "output/build" directory and a full "release"
  47. distribution.
  48. (3) Configure Environment Variables
  49. Tomcat is a Java application and does not use environment variables directly.
  50. Environment variables are used by the Tomcat startup scripts. The scripts use
  51. the environment variables to prepare the command that starts Tomcat.
  52. (3.1) Set CATALINA_HOME (required) and CATALINA_BASE (optional)
  53. The CATALINA_HOME environment variable should be set to the location of the
  54. root directory of the "binary" distribution of Tomcat.
  55. The Tomcat startup scripts have some logic to set this variable
  56. automatically if it is absent, based on the location of the startup script
  57. in *nix and on the current directory in Windows. That logic might not work
  58. in all circumstances, so setting the variable explicitly is recommended.
  59. The CATALINA_BASE environment variable specifies location of the root
  60. directory of the "active configuration" of Tomcat. It is optional. It
  61. defaults to be equal to CATALINA_HOME.
  62. Using distinct values for the CATALINA_HOME and CATALINA_BASE variables is
  63. recommended to simplify further upgrades and maintenance. It is documented
  64. in the "Multiple Tomcat Instances" section below.
  65. (3.2) Set JRE_HOME or JAVA_HOME (required)
  66. These variables are used to specify location of a Java Runtime
  67. Environment or of a Java Development Kit that is used to start Tomcat.
  68. The JRE_HOME variable is used to specify location of a JRE. The JAVA_HOME
  69. variable is used to specify location of a JDK.
  70. Using JAVA_HOME provides access to certain additional startup options that
  71. are not allowed when JRE_HOME is used.
  72. If both JRE_HOME and JAVA_HOME are specified, JRE_HOME is used.
  73. The recommended place to specify these variables is a "setenv" script. See
  74. below.
  75. (3.3) Other variables (optional)
  76. Other environment variables exist, besides the four described above.
  77. See the comments at the top of catalina.bat or catalina.sh scripts for
  78. the list and a description of each of them.
  79. One frequently used variable is CATALINA_OPTS. It allows specification of
  80. additional options for the java command that starts Tomcat.
  81. See the Java documentation for the options that affect the Java Runtime
  82. Environment.
  83. See the "System Properties" page in the Tomcat Configuration Reference for
  84. the system properties that are specific to Tomcat.
  85. A similar variable is JAVA_OPTS. It is used less frequently. It allows
  86. specification of options that are used both to start and to stop Tomcat as well
  87. as for other commands.
  88. Note: Do not use JAVA_OPTS to specify memory limits. You do not need much
  89. memory for a small process that is used to stop Tomcat. Those settings
  90. belong to CATALINA_OPTS.
  91. Another frequently used variable is CATALINA_PID (on *nix only). It
  92. specifies the location of the file where process id of the forked Tomcat
  93. java process will be written. This setting is optional. It will enable the
  94. following features:
  95. * better protection against duplicate start attempts and
  96. * allows forceful termination of Tomcat process when it does not react to
  97. the standard shutdown command.
  98. (3.4) Using the "setenv" script (optional, recommended)
  99. Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can
  100. be specified in the "setenv" script. The script is placed either into
  101. CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named
  102. setenv.bat (on Windows) or setenv.sh (on *nix). The file has to be
  103. readable.
  104. By default the setenv script file is absent. If the script file is present
  105. both in CATALINA_BASE and in CATALINA_HOME, the one in CATALINA_BASE is
  106. preferred.
  107. For example, to configure the JRE_HOME and CATALINA_PID variables you can
  108. create the following script file:
  109. On Windows, %CATALINA_BASE%\bin\setenv.bat:
  110. set "JRE_HOME=%ProgramFiles%\Java\jre7"
  111. exit /b 0
  112. On *nix, $CATALINA_BASE/bin/setenv.sh:
  113. JRE_HOME=/usr/java/latest
  114. CATALINA_PID="$CATALINA_BASE/tomcat.pid"
  115. The CATALINA_HOME and CATALINA_BASE variables cannot be configured in the
  116. setenv script, because they are used to locate that file.
  117. All the environment variables described here and the "setenv" script are
  118. used only if you use the standard scripts to launch Tomcat. For example, if
  119. you have installed Tomcat as a service on Windows, the service wrapper
  120. launches Java directly and does not use the script files.
  121. (4) Start Up Tomcat
  122. (4.1) Tomcat can be started by executing one of the following commands:
  123. On Windows:
  124. %CATALINA_HOME%\bin\startup.bat
  125. or
  126. %CATALINA_HOME%\bin\catalina.bat start
  127. On *nix:
  128. $CATALINA_HOME/bin/startup.sh
  129. or
  130. $CATALINA_HOME/bin/catalina.sh start
  131. (4.2) After startup, the default web applications included with Tomcat will be
  132. available by visiting:
  133. http://localhost:8080/
  134. (4.3) Further information about configuring and running Tomcat can be found in
  135. the documentation included here, as well as on the Tomcat web site:
  136. https://tomcat.apache.org/
  137. (5) Shut Down Tomcat
  138. (5.1) Tomcat can be shut down by executing one of the following commands:
  139. On Windows:
  140. %CATALINA_HOME%\bin\shutdown.bat
  141. or
  142. %CATALINA_HOME%\bin\catalina.bat stop
  143. On *nix:
  144. $CATALINA_HOME/bin/shutdown.sh
  145. or
  146. $CATALINA_HOME/bin/catalina.sh stop
  147. ==================================================
  148. Advanced Configuration - Multiple Tomcat Instances
  149. ==================================================
  150. In many circumstances, it is desirable to have a single copy of a Tomcat
  151. binary distribution shared among multiple users on the same server. To make
  152. this possible, you can set the CATALINA_BASE environment variable to the
  153. directory that contains the files for your 'personal' Tomcat instance.
  154. When running with a separate CATALINA_HOME and CATALINA_BASE, the files
  155. and directories are split as following:
  156. In CATALINA_BASE:
  157. * bin - Only the following files:
  158. * setenv.sh (*nix) or setenv.bat (Windows),
  159. * tomcat-juli.jar
  160. The setenv scripts were described above. The tomcat-juli library
  161. is documented in the Logging chapter in the User Guide.
  162. * conf - Server configuration files (including server.xml)
  163. * lib - Libraries and classes, as explained below
  164. * logs - Log and output files
  165. * webapps - Automatically loaded web applications
  166. * work - Temporary working directories for web applications
  167. * temp - Directory used by the JVM for temporary files (java.io.tmpdir)
  168. In CATALINA_HOME:
  169. * bin - Startup and shutdown scripts
  170. The following files will be used only if they are absent in
  171. CATALINA_BASE/bin:
  172. setenv.sh (*nix), setenv.bat (Windows), tomcat-juli.jar
  173. * lib - Libraries and classes, as explained below
  174. * endorsed - Libraries that override standard "Endorsed Standards"
  175. libraries provided by JRE. See Classloading documentation
  176. in the User Guide for details.
  177. This is only supported for Java <= 8.
  178. By default this "endorsed" directory is absent.
  179. In the default configuration the JAR libraries and classes both in
  180. CATALINA_BASE/lib and in CATALINA_HOME/lib will be added to the common
  181. classpath, but the ones in CATALINA_BASE will be added first and thus will
  182. be searched first.
  183. The idea is that you may leave the standard Tomcat libraries in
  184. CATALINA_HOME/lib and add other ones such as database drivers into
  185. CATALINA_BASE/lib.
  186. In general it is advised to never share libraries between web applications,
  187. but put them into WEB-INF/lib directories inside the applications. See
  188. Classloading documentation in the User Guide for details.
  189. It might be useful to note that the values of CATALINA_HOME and
  190. CATALINA_BASE can be referenced in the XML configuration files processed
  191. by Tomcat as ${catalina.home} and ${catalina.base} respectively.
  192. For example, the standard manager web application can be kept in
  193. CATALINA_HOME/webapps/manager and loaded into CATALINA_BASE by copying
  194. its deployment descriptor into the desired virtual host:
  195. * Copy the CATALINA_HOME/webapps/manager/META-INF/context.xml
  196. file as CATALINA_BASE/conf/Catalina/localhost/manager.xml
  197. * Add docBase attribute as shown below.
  198. The file will look like the following:
  199. <?xml version="1.0" encoding="UTF-8"?>
  200. <Context docBase="${catalina.home}/webapps/manager"
  201. antiResourceLocking="false" privileged="true" >
  202. <Valve className="org.apache.catalina.valves.RemoteAddrValve"
  203. allow="127\.0\.0\.1" />
  204. <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
  205. </Context>
  206. See Deployer chapter in User Guide and Context and Host chapters in the
  207. Configuration Reference for more information on contexts and web
  208. application deployment.
  209. ================
  210. Troubleshooting
  211. ================
  212. There are only really 2 things likely to go wrong during the stand-alone
  213. Tomcat install:
  214. (1) The most common hiccup is when another web server (or any process for that
  215. matter) has laid claim to port 8080. This is the default HTTP port that
  216. Tomcat attempts to bind to at startup. To change this, open the file:
  217. $CATALINA_HOME/conf/server.xml
  218. and search for '8080'. Change it to a port that isn't in use, and is
  219. greater than 1024, as ports less than or equal to 1024 require superuser
  220. access to bind under UNIX.
  221. Restart Tomcat and you're in business. Be sure that you replace the "8080"
  222. in the URL you're using to access Tomcat. For example, if you change the
  223. port to 1977, you would request the URL http://localhost:1977/ in your
  224. browser.
  225. (2) The 'localhost' machine isn't found. This could happen if you're behind a
  226. proxy. If that's the case, make sure the proxy configuration for your
  227. browser knows that you shouldn't be going through the proxy to access the
  228. "localhost".
  229. In Firefox, this is under Tools/Preferences -> Advanced/Network ->
  230. Connection -> Settings..., and in Internet Explorer it is Tools ->
  231. Internet Options -> Connections -> LAN Settings.
  232. ====================
  233. Optional Components
  234. ====================
  235. The following optional components may be included with the Apache Tomcat binary
  236. distribution. If they are not included, you can install them separately.
  237. 1. Apache Tomcat Native library
  238. 2. Apache Commons Daemon service launcher
  239. Both of them are implemented in C language and as such have to be compiled
  240. into binary code. The binary code will be specific for a platform and CPU
  241. architecture and it must match the Java Runtime Environment executables
  242. that will be used to launch Tomcat.
  243. The Windows-specific binary distributions of Apache Tomcat include binary
  244. files for these components. On other platforms you would have to look for
  245. binary versions elsewhere or compile them yourself.
  246. If you are new to Tomcat, do not bother with these components to start with.
  247. If you do use them, do not forget to read their documentation.
  248. Apache Tomcat Native library
  249. -----------------------------
  250. It is a library that allows to use the "Apr" variant of HTTP and AJP
  251. protocol connectors in Apache Tomcat. It is built around OpenSSL and Apache
  252. Portable Runtime (APR) libraries. Those are the same libraries as used by
  253. Apache HTTPD Server project.
  254. This feature was especially important in the old days when Java performance
  255. was poor. It is less important nowadays, but it is still used and respected
  256. by many. See Tomcat documentation for more details.
  257. For further reading:
  258. - Apache Tomcat documentation
  259. * Documentation for APR/Native library in the Tomcat User's Guide
  260. https://tomcat.apache.org/tomcat-8.5-doc/apr.html
  261. * Documentation for the HTTP and AJP protocol connectors in the Tomcat
  262. Configuration Reference
  263. https://tomcat.apache.org/tomcat-8.5-doc/config/http.html
  264. https://tomcat.apache.org/tomcat-8.5-doc/config/ajp.html
  265. - Apache Tomcat Native project home
  266. https://tomcat.apache.org/native-doc/
  267. - Other projects
  268. * OpenSSL
  269. https://www.openssl.org/
  270. * Apache Portable Runtime
  271. https://apr.apache.org/
  272. * Apache HTTP Server
  273. https://httpd.apache.org/
  274. To disable Apache Tomcat Native library:
  275. - To disable Apache Tomcat Native library when it is installed, or
  276. - To remove the warning that is logged during Tomcat startup when the
  277. library is not installed:
  278. Edit the "conf/server.xml" file and remove "AprLifecycleListener" from
  279. it.
  280. The binary file of Apache Tomcat Native library is usually named
  281. - "tcnative-1.dll" on Windows
  282. - "libtcnative-1.so" on *nix systems
  283. Apache Commons Daemon
  284. ----------------------
  285. Apache Commons Daemon project provides wrappers that can be used to
  286. install Apache Tomcat as a service on Windows or as a daemon on *nix
  287. systems.
  288. The Windows-specific implementation of Apache Commons Daemon is called
  289. "procrun". The *nix-specific one is called "jsvc".
  290. For further reading:
  291. - Apache Commons Daemon project
  292. https://commons.apache.org/daemon/
  293. - Apache Tomcat documentation
  294. * Installing Apache Tomcat
  295. https://tomcat.apache.org/tomcat-8.5-doc/setup.html
  296. * Windows Service How-To
  297. https://tomcat.apache.org/tomcat-8.5-doc/windows-service-howto.html
  298. The binary files of Apache Commons Daemon in Apache Tomcat distributions
  299. for Windows are named:
  300. - "tomcat8.exe"
  301. - "tomcat8w.exe"
  302. These files are renamed copies of "prunsrv.exe" and "prunmgr.exe" from
  303. Apache Commons Daemon distribution. The file names have a meaning: they are
  304. used as the service name to register the service in Windows, as well as the
  305. key name to store distinct configuration for this installation of
  306. "procrun". If you would like to install several instances of Tomcat 8.5
  307. in parallel, you have to further rename those files, using the same naming
  308. scheme.