blob: 2c2c257bdfbaadda57d011e6f6ae5afa20400b8b [file] [log] [blame]
刘洪青6266f992017-05-15 21:21:03 +08001<html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Apache Tomcat 7 (7.0.77) - Windows service HOW-TO</title><meta name="author" content="Mladen Turk"><style type="text/css" media="print">
2 .noPrint {display: none;}
3 td#mainBody {width: 100%;}
4</style><style type="text/css">
5code {background-color:rgb(224,255,255);padding:0 0.1em;}
6code.attributeName, code.propertyName {background-color:transparent;}
7
8
9table {
10 border-collapse: collapse;
11 text-align: left;
12}
13table *:not(table) {
14 /* Prevent border-collapsing for table child elements like <div> */
15 border-collapse: separate;
16}
17
18th {
19 text-align: left;
20}
21
22
23div.codeBox pre code, code.attributeName, code.propertyName, code.noHighlight, .noHighlight code {
24 background-color: transparent;
25}
26div.codeBox {
27 overflow: auto;
28 margin: 1em 0;
29}
30div.codeBox pre {
31 margin: 0;
32 padding: 4px;
33 border: 1px solid #999;
34 border-radius: 5px;
35 background-color: #eff8ff;
36 display: table; /* To prevent <pre>s from taking the complete available width. */
37 /*
38 When it is officially supported, use the following CSS instead of display: table
39 to prevent big <pre>s from exceeding the browser window:
40 max-width: available;
41 width: min-content;
42 */
43}
44
45div.codeBox pre.wrap {
46 white-space: pre-wrap;
47}
48
49
50table.defaultTable tr, table.detail-table tr {
51 border: 1px solid #CCC;
52}
53
54table.defaultTable tr:nth-child(even), table.detail-table tr:nth-child(even) {
55 background-color: #FAFBFF;
56}
57
58table.defaultTable tr:nth-child(odd), table.detail-table tr:nth-child(odd) {
59 background-color: #EEEFFF;
60}
61
62table.defaultTable th, table.detail-table th {
63 background-color: #88b;
64 color: #fff;
65}
66
67table.defaultTable th, table.defaultTable td, table.detail-table th, table.detail-table td {
68 padding: 5px 8px;
69}
70
71
72p.notice {
73 border: 1px solid rgb(255, 0, 0);
74 background-color: rgb(238, 238, 238);
75 color: rgb(0, 51, 102);
76 padding: 0.5em;
77 margin: 1em 2em 1em 1em;
78}
79</style></head><body bgcolor="#ffffff" text="#000000" link="#525D76" alink="#525D76" vlink="#525D76"><table border="0" width="100%" cellspacing="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img src="./images/tomcat.gif" align="right" alt="
Hongqing Liufd5ee812014-05-10 16:32:51 +080080 The Apache Tomcat Servlet/JSP Container
刘洪青6266f992017-05-15 21:21:03 +080081 " border="0"></a></td><td><h1><font face="arial,helvetica,sanserif">Apache Tomcat 7</font></h1><font face="arial,helvetica,sanserif">Version 7.0.77, Mar 28 2017</font></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img src="./images/asf-logo.svg" align="right" alt="Apache Logo" border="0" style="width: 266px;height: 83px;"></a></td></tr></table><table border="0" width="100%" cellspacing="4"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><tr><!--LEFT SIDE NAVIGATION--><td width="20%" valign="top" nowrap class="noPrint"><p><strong>Links</strong></p><ul><li><a href="index.html">Docs Home</a></li><li><a href="http://wiki.apache.org/tomcat/FAQ">FAQ</a></li><li><a href="#comments_section">User Comments</a></li></ul><p><strong>User Guide</strong></p><ul><li><a href="introduction.html">1) Introduction</a></li><li><a href="setup.html">2) Setup</a></li><li><a href="appdev/index.html">3) First webapp</a></li><li><a href="deployer-howto.html">4) Deployer</a></li><li><a href="manager-howto.html">5) Manager</a></li><li><a href="realm-howto.html">6) Realms and AAA</a></li><li><a href="security-manager-howto.html">7) Security Manager</a></li><li><a href="jndi-resources-howto.html">8) JNDI Resources</a></li><li><a href="jndi-datasource-examples-howto.html">9) JDBC DataSources</a></li><li><a href="class-loader-howto.html">10) Classloading</a></li><li><a href="jasper-howto.html">11) JSPs</a></li><li><a href="ssl-howto.html">12) SSL/TLS</a></li><li><a href="ssi-howto.html">13) SSI</a></li><li><a href="cgi-howto.html">14) CGI</a></li><li><a href="proxy-howto.html">15) Proxy Support</a></li><li><a href="mbeans-descriptors-howto.html">16) MBeans Descriptors</a></li><li><a href="default-servlet.html">17) Default Servlet</a></li><li><a href="cluster-howto.html">18) Clustering</a></li><li><a href="balancer-howto.html">19) Load Balancer</a></li><li><a href="connectors.html">20) Connectors</a></li><li><a href="monitoring.html">21) Monitoring and Management</a></li><li><a href="logging.html">22) Logging</a></li><li><a href="apr.html">23) APR/Native</a></li><li><a href="virtual-hosting-howto.html">24) Virtual Hosting</a></li><li><a href="aio.html">25) Advanced IO</a></li><li><a href="extras.html">26) Additional Components</a></li><li><a href="maven-jars.html">27) Mavenized</a></li><li><a href="security-howto.html">28) Security Considerations</a></li><li><a href="windows-service-howto.html">29) Windows Service</a></li><li><a href="windows-auth-howto.html">30) Windows Authentication</a></li><li><a href="jdbc-pool.html">31) Tomcat's JDBC Pool</a></li><li><a href="web-socket-howto.html">32) WebSocket</a></li></ul><p><strong>Reference</strong></p><ul><li><a href="RELEASE-NOTES.txt">Release Notes</a></li><li><a href="config/index.html">Configuration</a></li><li><a href="api/index.html">Tomcat Javadocs</a></li><li><a href="servletapi/index.html">Servlet Javadocs</a></li><li><a href="jspapi/index.html">JSP 2.2 Javadocs</a></li><li><a href="elapi/index.html">EL 2.2 Javadocs</a></li><li><a href="websocketapi/index.html">WebSocket 1.1 Javadocs</a></li><li><a href="http://tomcat.apache.org/connectors-doc/">JK 1.2 Documentation</a></li></ul><p><strong>Apache Tomcat Development</strong></p><ul><li><a href="building.html">Building</a></li><li><a href="changelog.html">Changelog</a></li><li><a href="http://wiki.apache.org/tomcat/TomcatVersions">Status</a></li><li><a href="developers.html">Developers</a></li><li><a href="architecture/index.html">Architecture</a></li><li><a href="funcspecs/index.html">Functional Specs.</a></li><li><a href="tribes/introduction.html">Tribes</a></li></ul></td><!--RIGHT SIDE MAIN BODY--><td width="80%" valign="top" align="left" id="mainBody"><h1>Windows service HOW-TO</h1><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Table of Contents"><!--()--></a><a name="Table_of_Contents"><strong>Table of Contents</strong></a></font></td></tr><tr><td><blockquote>
82<ul><li><a href="#Tomcat_service_application">Tomcat service application</a></li><li><a href="#Tomcat_monitor_application">Tomcat monitor application</a></li><li><a href="#Command_line_arguments">Command line arguments</a></li><li><a href="#Command_line_parameters">Command line parameters</a></li><li><a href="#Installing_services">Installing services</a></li><li><a href="#Updating_services">Updating services</a></li><li><a href="#Removing_services">Removing services</a></li><li><a href="#Debugging_services">Debugging services</a></li><li><a href="#Multiple_Instances">Multiple Instances</a></li></ul>
83</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Tomcat service application"><!--()--></a><a name="Tomcat_service_application"><strong>Tomcat service application</strong></a></font></td></tr><tr><td><blockquote>
Hongqing Liufd5ee812014-05-10 16:32:51 +080084<p>
刘洪青6266f992017-05-15 21:21:03 +080085 <b>Tomcat7</b> is a service application for running Tomcat
86 7 as a Windows service.
Hongqing Liufd5ee812014-05-10 16:32:51 +080087</p>
刘洪青6266f992017-05-15 21:21:03 +080088</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Tomcat monitor application"><!--()--></a><a name="Tomcat_monitor_application"><strong>Tomcat monitor application</strong></a></font></td></tr><tr><td><blockquote>
Hongqing Liufd5ee812014-05-10 16:32:51 +080089<p>
刘洪青6266f992017-05-15 21:21:03 +080090 <b>Tomcat7w</b> is a GUI application for monitoring and
91 configuring Tomcat services.
92</p>
Hongqing Liufd5ee812014-05-10 16:32:51 +080093 <p>The available command line options are:</p>
刘洪青6266f992017-05-15 21:21:03 +080094
95 <table class="defaultTable">
96 <tr><td><b>//ES//</b></td>
Hongqing Liufd5ee812014-05-10 16:32:51 +080097 <td>Edit service configuration</td>
98 <td>This is the default operation. It is called if the no option is
99 provided but the executable is renamed to <b>servicenameW.exe</b></td>
100 </tr>
刘洪青6266f992017-05-15 21:21:03 +0800101 <tr><td><b>//MS//</b></td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800102 <td>Monitor service</td>
103 <td>Put the icon in the system tray</td>
104 </tr>
105 </table>
刘洪青6266f992017-05-15 21:21:03 +0800106
Hongqing Liufd5ee812014-05-10 16:32:51 +0800107</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Command line arguments"><!--()--></a><a name="Command_line_arguments"><strong>Command line arguments</strong></a></font></td></tr><tr><td><blockquote>
108<p>
109 Each command line directive is in the form of <b>//XX//ServiceName</b>
110</p>
111 <p>The available command line options are:</p>
刘洪青6266f992017-05-15 21:21:03 +0800112
113 <table class="defaultTable">
114 <tr><td><b>//TS//</b></td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800115 <td>Run the service as console application</td>
116 <td>This is the default operation. It is called if the no option is
117 provided. The ServiceName is the name of the executable without
刘洪青6266f992017-05-15 21:21:03 +0800118 exe suffix, meaning Tomcat7</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800119 </tr>
刘洪青6266f992017-05-15 21:21:03 +0800120 <tr><td><b>//RS//</b></td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800121 <td>Run the service</td>
122 <td>Called only from ServiceManager</td>
123 </tr>
刘洪青6266f992017-05-15 21:21:03 +0800124 <tr><td><b>//SS//</b></td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800125 <td>Stop the service</td>
126 <td></td>
127 </tr>
刘洪青6266f992017-05-15 21:21:03 +0800128 <tr><td><b>//US//</b></td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800129 <td>Update service parameters</td>
130 <td></td>
131 </tr>
刘洪青6266f992017-05-15 21:21:03 +0800132 <tr><td><b>//IS//</b></td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800133 <td>Install service</td>
134 <td></td>
135 </tr>
刘洪青6266f992017-05-15 21:21:03 +0800136 <tr><td><b>//DS//</b></td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800137 <td>Delete service</td>
138 <td>Stops the service if running</td>
刘洪青6266f992017-05-15 21:21:03 +0800139 </tr>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800140 </table>
刘洪青6266f992017-05-15 21:21:03 +0800141
Hongqing Liufd5ee812014-05-10 16:32:51 +0800142</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Command line parameters"><!--()--></a><a name="Command_line_parameters"><strong>Command line parameters</strong></a></font></td></tr><tr><td><blockquote>
143<p>
144 Each command parameter is prefixed with <b>--</b>.
145 If the command line is prefixed with <b>++</b> then it's value will
146 be appended to the existing option.
147 If the environment variable with the same name as command line parameter but
148 prefixed with <code>PR_</code> exists it will take precedence.
刘洪青6266f992017-05-15 21:21:03 +0800149 For example:</p>
150<div class="codeBox"><pre><code>set PR_CLASSPATH=xx.jar</code></pre></div>
151
152<p>is equivalent to providing</p>
153<div class="codeBox"><pre><code>--Classpath=xx.jar</code></pre></div>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800154<p> as command line parameter.</p>
刘洪青6266f992017-05-15 21:21:03 +0800155
156 <table class="defaultTable">
Hongqing Liufd5ee812014-05-10 16:32:51 +0800157 <tr>
158 <th>ParameterName</th>
刘洪青6266f992017-05-15 21:21:03 +0800159 <th>Default</th>
160 <th>Description</th>
161 </tr>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800162 <tr>
163 <td>--Description</td>
164 <td></td>
165 <td>Service name description (maximum 1024 characters)</td>
166 </tr>
167 <tr>
168 <td>--DisplayName</td>
169 <td>ServiceName</td>
170 <td>Service display name</td>
171 </tr>
172 <tr>
173 <td>--Install</td>
174 <td>procrun.exe //RS//ServiceName</td>
175 <td>Install image</td>
176 </tr>
177 <tr>
178 <td>--Startup</td>
179 <td>manual</td>
180 <td>Service startup mode can be either <b>auto</b> or <b>manual</b></td>
181 </tr>
182 <tr>
Hongqing Liu71898292014-10-15 13:31:32 +0800183 <td>++DependsOn</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800184 <td></td>
185 <td>List of services that this service depend on. Dependent services
186 are separated using either <b>#</b> or <b>;</b> characters</td>
187 </tr>
188 <tr>
Hongqing Liu71898292014-10-15 13:31:32 +0800189 <td>++Environment</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800190 <td></td>
191 <td>List of environment variables that will be provided to the service
192 in the form <b>key=value</b>. They are separated using either
193 <b>#</b> or <b>;</b> characters. If you need to use either the <b>#</b>
194 or <b>;</b> character within a value then the entire value must be
195 enclosed inside single quotes.</td>
196 </tr>
197 <tr>
198 <td>--User</td>
199 <td></td>
200 <td>User account used for running executable. It is used only for
刘洪青6266f992017-05-15 21:21:03 +0800201 StartMode <b>java</b> or <b>exe</b> and enables running applications
202 as service under account without LogonAsService privilege.</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800203 </tr>
204 <tr>
205 <td>--Password</td>
206 <td></td>
207 <td>Password for user account set by --User parameter</td>
208 </tr>
209 <tr>
210 <td>--JavaHome</td>
211 <td>JAVA_HOME</td>
212 <td>Set a different JAVA_HOME than defined by JAVA_HOME environment
213 variable</td>
214 </tr>
215 <tr>
216 <td>--Jvm</td>
217 <td>auto</td>
Hongqing Liu71898292014-10-15 13:31:32 +0800218 <td>Use either <b>auto</b> (i.e. find the JVM from the Windows registry)
219 or specify the full path to the <b>jvm.dll</b>.
Hongqing Liufd5ee812014-05-10 16:32:51 +0800220 You can use the environment variable expansion here.</td>
221 </tr>
222 <tr>
Hongqing Liu71898292014-10-15 13:31:32 +0800223 <td>++JvmOptions</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800224 <td>-Xrs</td>
225 <td>List of options in the form of <b>-D</b> or <b>-X</b> that will be
226 passed to the JVM. The options are separated using either
Hongqing Liu71898292014-10-15 13:31:32 +0800227 <b>#</b> or <b>;</b> characters. (Not used in <b>exe</b> mode.)</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800228 </tr>
229 <tr>
230 <td>--Classpath</td>
231 <td></td>
Hongqing Liu71898292014-10-15 13:31:32 +0800232 <td>Set the Java classpath. (Not used in <b>exe</b> mode.)</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800233 </tr>
234 <tr>
235 <td>--JvmMs</td>
236 <td></td>
Hongqing Liu71898292014-10-15 13:31:32 +0800237 <td>Initial memory pool size in MB. (Not used in <b>exe</b> mode.)</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800238 </tr>
239 <tr>
240 <td>--JvmMx</td>
241 <td></td>
Hongqing Liu71898292014-10-15 13:31:32 +0800242 <td>Maximum memory pool size in MB. (Not used in <b>exe</b> mode.)</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800243 </tr>
244 <tr>
245 <td>--JvmSs</td>
246 <td></td>
Hongqing Liu71898292014-10-15 13:31:32 +0800247 <td>Thread stack size in KB. (Not used in <b>exe</b> mode.)</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800248 </tr>
249 <tr>
Hongqing Liu71898292014-10-15 13:31:32 +0800250 <td>--StartMode</td>
251 <td></td>
252 <td>One of <b>jvm</b>, <b>Java</b> or <b>exe</b>. The modes are:
253 <ul>
254 <li>jvm - start Java in-process. Depends on jvm.dll, see <b>--Jvm</b>.</li>
255 <li>Java - same as exe, but automatically uses the default Java
256 executable, i.e. %JAVA_HOME%\bin\java.exe. Make sure JAVA_HOME is set
257 correctly, or use --JavaHome to provide the correct location.
258 If neither is set, procrun will try to find the default JDK (not JRE)
259 from the Windows registry.</li>
260 <li>exe - run the image as a separate process</li>
261 </ul>
262 </td>
263 </tr>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800264 <tr>
265 <td>--StartImage</td>
266 <td></td>
Hongqing Liu71898292014-10-15 13:31:32 +0800267 <td>Executable that will be run. Only applies to <b>exe</b> mode.</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800268 </tr>
269 <tr>
270 <td>--StartPath</td>
271 <td></td>
272 <td>Working path for the start image executable.</td>
273 </tr>
274 <tr>
275 <td>--StartClass</td>
Hongqing Liu71898292014-10-15 13:31:32 +0800276 <td>Main</td>
277 <td>Class that contains the startup method. Applies to the <b>jvm</b> and
278 <b>Java</b> modes. (Not used in <b>exe</b> mode.) </td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800279 </tr>
280 <tr>
Hongqing Liu71898292014-10-15 13:31:32 +0800281 <td>--StartMethod</td>
282 <td>main</td>
283 <td>Method name if differs then main</td>
284 </tr>
285 <tr>
286 <td>++StartParams</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800287 <td></td>
288 <td>List of parameters that will be passed to either StartImage or
289 StartClass. Parameters are separated using either <b>#</b> or
290 <b>;</b> character.</td>
291 </tr>
292 <tr>
Hongqing Liu71898292014-10-15 13:31:32 +0800293 <td>--StopMode</td>
294 <td></td>
295 <td>One of <b>jvm</b>, <b>Java</b> or <b>exe</b>. See <b>--StartMode</b>
296 for further details. </td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800297 </tr>
298 <tr>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800299 <td>--StopImage</td>
300 <td></td>
Hongqing Liu71898292014-10-15 13:31:32 +0800301 <td>Executable that will be run on Stop service signal. Only applies to
302 <b>exe</b> mode.</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800303 </tr>
304 <tr>
305 <td>--StopPath</td>
306 <td></td>
Hongqing Liu71898292014-10-15 13:31:32 +0800307 <td>Working path for the stop image executable. Does not apply to <b>jvm</b>
308 mode.</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800309 </tr>
310 <tr>
311 <td>--StopClass</td>
Hongqing Liu71898292014-10-15 13:31:32 +0800312 <td>Main</td>
313 <td>Class that will be used on Stop service signal. Applies to the
314 <b>jvm</b> and <b>Java</b> modes. </td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800315 </tr>
316 <tr>
Hongqing Liu71898292014-10-15 13:31:32 +0800317 <td>--StopMethod</td>
318 <td>main</td>
319 <td>Method name if differs then main</td>
320 </tr>
321 <tr>
322 <td>++StopParams</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800323 <td></td>
324 <td>List of parameters that will be passed to either StopImage or
325 StopClass. Parameters are separated using either <b>#</b> or
326 <b>;</b> character.</td>
327 </tr>
328 <tr>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800329 <td>--StopTimeout</td>
330 <td>No Timeout</td>
331 <td>Defines the timeout in seconds that procrun waits for service to
332 exit gracefully.</td>
333 </tr>
334 <tr>
335 <td>--LogPath</td>
Hongqing Liu71898292014-10-15 13:31:32 +0800336 <td>%SystemRoot%\System32\LogFiles\Apache</td>
337 <td>Defines the path for logging. Creates the directory if necessary.</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800338 </tr>
339 <tr>
340 <td>--LogPrefix</td>
Hongqing Liu71898292014-10-15 13:31:32 +0800341 <td>commons-daemon</td>
342 <td>Defines the service log filename prefix. The log file is created in the
343 LogPath directory with <code>.YEAR-MONTH-DAY.log</code> suffix</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800344 </tr>
345 <tr>
346 <td>--LogLevel</td>
Hongqing Liu71898292014-10-15 13:31:32 +0800347 <td>Info</td>
348 <td>Defines the logging level and can be either <b>Error</b>,
349 <b>Info</b>, <b>Warn</b> or <b>Debug</b>. (Case insensitive).</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800350 </tr>
351 <tr>
352 <td>--StdOutput</td>
353 <td></td>
Hongqing Liu71898292014-10-15 13:31:32 +0800354 <td>Redirected stdout filename.
355 If named <b>auto</b> then file is created inside <b>LogPath</b> with the
356 name <b>service-stdout.YEAR-MONTH-DAY.log</b>.</td>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800357 </tr>
358 <tr>
359 <td>--StdError</td>
360 <td></td>
Hongqing Liu71898292014-10-15 13:31:32 +0800361 <td>Redirected stderr filename.
362 If named <b>auto</b> then file is created inside <b>LogPath</b> with the
363 name <b>service-stderr.YEAR-MONTH-DAY.log</b>.</td>
刘洪青6266f992017-05-15 21:21:03 +0800364 </tr>
Hongqing Liu71898292014-10-15 13:31:32 +0800365 <tr>
366 <td>--PidFile</td>
367 <td></td>
368 <td>Defines the file name for storing the running process id. Actual file is
369 created in the <b>LogPath</b> directory</td>
370 </tr>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800371 </table>
刘洪青6266f992017-05-15 21:21:03 +0800372
Hongqing Liufd5ee812014-05-10 16:32:51 +0800373</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Installing services"><!--()--></a><a name="Installing_services"><strong>Installing services</strong></a></font></td></tr><tr><td><blockquote>
374<p>
375The safest way to manually install the service is to use the provided
376<b>service.bat</b> script. Administrator privileges are required to run this
刘洪青6266f992017-05-15 21:21:03 +0800377script. If necessary, you can use the <code>/user</code> switch to specify
378a user to use for the installation of the service.
Hongqing Liufd5ee812014-05-10 16:32:51 +0800379</p>
380<p>
Hongqing Liu71898292014-10-15 13:31:32 +0800381<strong>NOTE:</strong> On Windows Vista or any later operating system with User
382Account Control (UAC) enabled you will be asked for additional privileges
刘洪青6266f992017-05-15 21:21:03 +0800383when 'Tomcat7.exe' is launched by the script.<br>
Hongqing Liu71898292014-10-15 13:31:32 +0800384If you want to pass additional options to service installer as
385<code>PR_*</code> environment variables, you have to either configure them
386globally in OS, or launch the program that sets them with elevated privileges
387(e.g. right-click on cmd.exe and select "Run as administrator"; on Windows 8
388(or later) or Windows Server 2012 (or later), you can open an elevated command
389prompt for the current directory from the Explorer
刘洪青6266f992017-05-15 21:21:03 +0800390by clicking on the "File" menu bar). See issue <a href="http://bz.apache.org/bugzilla/show_bug.cgi?id=56143">56143</a> for details.
Hongqing Liufd5ee812014-05-10 16:32:51 +0800391</p>
刘洪青6266f992017-05-15 21:21:03 +0800392
393<div class="codeBox"><pre><code>Install the service named 'Tomcat7'
394C:\&gt; service.bat install</code></pre></div>
395
396<p>There is a 2nd optional parameter that lets you specify the name of the
397service, as displayed in Windows services.</p>
398
399<div class="codeBox"><pre><code>Install the service named 'MyService'
400C:\&gt; service.bat install MyService</code></pre></div>
401
Hongqing Liufd5ee812014-05-10 16:32:51 +0800402<p>
刘洪青6266f992017-05-15 21:21:03 +0800403If using tomcat7.exe, you need to use the <b>//IS//</b> parameter.</p>
404
405<div class="codeBox"><pre><code>Install the service named 'Tomcat7'
406C:\&gt; tomcat7 //IS//Tomcat7 --DisplayName="Apache Tomcat 7" ^
407 --Install="C:\Program Files\Tomcat\bin\tomcat7.exe" --Jvm=auto ^
408 --StartMode=jvm --StopMode=jvm ^
409 --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start ^
410 --StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop</code></pre></div>
411
Hongqing Liufd5ee812014-05-10 16:32:51 +0800412</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Updating services"><!--()--></a><a name="Updating_services"><strong>Updating services</strong></a></font></td></tr><tr><td><blockquote>
413<p>
414To update the service parameters, you need to use the <b>//US//</b> parameter.
415</p>
刘洪青6266f992017-05-15 21:21:03 +0800416
417<div class="codeBox"><pre><code>Update the service named 'Tomcat7'
418C:\&gt; tomcat7 //US//Tomcat7 --Description="Apache Tomcat Server - http://tomcat.apache.org/ " ^
419 --Startup=auto --Classpath=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar</code></pre></div>
420
421<p>If you gave the service an optional name, you need to specify it like this:
Hongqing Liufd5ee812014-05-10 16:32:51 +0800422</p>
刘洪青6266f992017-05-15 21:21:03 +0800423
424<div class="codeBox"><pre><code>Update the service named 'MyService'
425C:\&gt; tomcat7 //US//MyService --Description="Apache Tomcat Server - http://tomcat.apache.org/ " ^
426 --Startup=auto --Classpath=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar</code></pre></div>
427
Hongqing Liufd5ee812014-05-10 16:32:51 +0800428</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Removing services"><!--()--></a><a name="Removing_services"><strong>Removing services</strong></a></font></td></tr><tr><td><blockquote>
429<p>
430To remove the service, you need to use the <b>//DS//</b> parameter.<br>
刘洪青6266f992017-05-15 21:21:03 +0800431If the service is running it will be stopped and then deleted.</p>
432
433<div class="codeBox"><pre><code>Remove the service named 'Tomcat7'
434C:\&gt; tomcat7 //DS//Tomcat7</code></pre></div>
435
436<p>If you gave the service an optional name, you need to specify it like this:
Hongqing Liufd5ee812014-05-10 16:32:51 +0800437</p>
刘洪青6266f992017-05-15 21:21:03 +0800438
439<div class="codeBox"><pre><code>Remove the service named 'MyService'
440C:\&gt; tomcat7 //DS//MyService</code></pre></div>
441
Hongqing Liufd5ee812014-05-10 16:32:51 +0800442</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Debugging services"><!--()--></a><a name="Debugging_services"><strong>Debugging services</strong></a></font></td></tr><tr><td><blockquote>
443<p>
444To run the service in console mode, you need to use the <b>//TS//</b> parameter.
445The service shutdown can be initiated by pressing <b>CTRL+C</b> or
446<b>CTRL+BREAK</b>.
刘洪青6266f992017-05-15 21:21:03 +0800447If you rename the tomcat7.exe to testservice.exe then you can just execute the
448testservice.exe and this command mode will be executed by default.</p>
449
450<div class="codeBox"><pre><code>Run the service named 'Tomcat7' in console mode
451C:\&gt; tomcat7 //TS//Tomcat7 [additional arguments]
452Or simply execute:
453C:\&gt; tomcat7</code></pre></div>
454
455</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Multiple Instances"><!--()--></a><a name="Multiple_Instances"><strong>Multiple Instances</strong></a></font></td></tr><tr><td><blockquote>
456<p>
457Tomcat supports installation of multiple instances. You can have a single
458installation of Tomcat with multiple instances running on different IP/port
459combinations, or multiple Tomcat versions, each running one or more instances on
460different IP/ports.</p>
461<p>
462Each instance folder will need the following structure:
463</p>
464<ul>
465<li>conf</li>
466<li>logs</li>
467<li>temp</li>
468<li>webapps</li>
469<li>work</li>
470</ul>
471<p>
472At a minimum, conf should contain a copy of the following files from
473CATALINA_HOME\conf\. Any files not copied and edited, will be picked up by
474default from CATALINA_HOME\conf, i.e. CATALINA_BASE\conf files override defaults
475from CATALINA_HOME\conf.</p>
476<ul>
477<li>server.xml</li>
478<li>web.xml</li>
479</ul>
480<p>
481You must edit CATALINA_BASE\conf\server.xml to specify a unique IP/port for the
482instance to listen on. Find the line that contains
483<code>&lt;Connector port="8080" ...</code> and add an address attribute and/or
484update the port number so as to specify a unique IP/port combination.</p>
485<p>
486To install an instance, first set the CATALINA_HOME environment variable to the
487name of the Tomcat installation directory. Then create a second environment
488variable CATALINA_BASE and point this to the instance folder. Then run "service
489install" command specifying a service name.</p>
490
491<div class="codeBox"><pre><code>set CATALINA_HOME=c:\tomcat_7
492set CATALINA_BASE=c:\tomcat_7\instances\instance1
493service install instance1</code></pre></div>
494
495<p>
496To modify the service settings, you can run <b>tomcat7w //ES//instance1</b>.
Hongqing Liufd5ee812014-05-10 16:32:51 +0800497</p>
498<p>
刘洪青6266f992017-05-15 21:21:03 +0800499For additional instances, create additional instance folder, update the
500CATALINA_BASE environment variable, and run the service install again.</p>
501
502<div class="codeBox"><pre><code>set CATALINA_BASE=c:\tomcat_7\instances\instance2
503service install instance2</code></pre></div>
504
505</blockquote></td></tr></table></td></tr><tr class="noPrint"><td width="20%" valign="top" nowrap class="noPrint"></td><td width="80%" valign="top" align="left"><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="comments_section" id="comments_section"><strong>Comments</strong></a></font></td></tr><tr><td><blockquote><p class="notice"><strong>Notice: </strong>This comments section collects your suggestions
506 on improving documentation for Apache Tomcat.<br><br>
507 If you have trouble and need help, read
508 <a href="http://tomcat.apache.org/findhelp.html">Find Help</a> page
509 and ask your question on the tomcat-users
510 <a href="http://tomcat.apache.org/lists.html">mailing list</a>.
511 Do not ask such questions here. This is not a Q&amp;A section.<br><br>
512 The Apache Comments System is explained <a href="./comments.html">here</a>.
513 Comments may be removed by our moderators if they are either
514 implemented or considered invalid/off-topic.</p><script type="text/javascript"><!--//--><![CDATA[//><!--
515 var comments_shortname = 'tomcat';
516 var comments_identifier = 'http://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html';
517 (function(w, d) {
518 if (w.location.hostname.toLowerCase() == "tomcat.apache.org") {
519 d.write('<div id="comments_thread"><\/div>');
520 var s = d.createElement('script');
521 s.type = 'text/javascript';
522 s.async = true;
523 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
524 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
525 }
526 else {
527 d.write('<div id="comments_thread"><strong>Comments are disabled for this page at the moment.<\/strong><\/div>');
528 }
529 })(window, document);
530 //--><!]]></script></blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font color="#525D76" size="-1"><em>
531 Copyright &copy; 1999-2017, Apache Software Foundation
Hongqing Liufd5ee812014-05-10 16:32:51 +0800532 </em></font></div></td></tr></table></body></html>