1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7 --><title>Using Apache with Microsoft Windows - Apache HTTP Server</title><link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /><link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /><link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link href="../images/favicon.ico" rel="shortcut icon" /></head><body id="manual-page"><div id="page-header"><p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p><p class="apache">Apache HTTP Server Version 2.0</p><img alt="" src="../images/feather.gif" /></div><div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div><div id="path"><a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.0</a></div><div id="page-content"><div id="preamble"><h1>Using Apache with Microsoft Windows</h1>
9 <p>This document explains how to install, configure and run
10 Apache 2.0 under Microsoft Windows. If you find any bugs, or
11 wish to contribute in other ways, please use our <a href="http://httpd.apache.org/bug_report.html">bug reporting page.</a></p>
13 <p>Most of this document assumes that you are installing
14 Windows from a binary distribution. If you want to compile
15 Apache yourself (possibly to help with development, or to track
16 down bugs), see <a href="win_compiling.html">Compiling Apache
17 for Microsoft Windows</a>.</p>
19 <p><strong>At this time, support for Windows 95, 98 and ME is
20 incomplete. Apache 2.0 is not expected to work on those
21 platforms at this time.</strong> If you are interested in
22 helping with that effort, please see the developer's site for
23 information on <a href="http://dev.apache.org/">how to get
24 involved</a>. Support will likely be provided at some point in
25 the future, and patches to allow Apache to work on 95, 98 and
28 </div><div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#req">Requirements</a></li><li><img alt="" src="../images/down.gif" /> <a href="#down">Downloading Apache for Windows</a></li><li><img alt="" src="../images/down.gif" /> <a href="#inst">Installing Apache for Windows</a></li><li><img alt="" src="../images/down.gif" /> <a href="#run">Running Apache for Windows</a></li><li><img alt="" src="../images/down.gif" /> <a href="#use">Configuring Apache for Windows</a></li><li><img alt="" src="../images/down.gif" /> <a href="#service">Running Apache for Windows as a Service</a></li><li><img alt="" src="../images/down.gif" /> <a href="#cmdline">Running Apache for Windows from the Command Line</a></li><li><img alt="" src="../images/down.gif" /> <a href="#signalsrv">Signalling Service Apache when running</a></li><li><img alt="" src="../images/down.gif" /> <a href="#signal">Signalling Console Apache when running</a></li></ul></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="req" id="req">Requirements</a></h2>
32 <p>Apache 2.0 is designed to run on Windows NT 4.0 and Windows
33 2000. The binary installer will only work with the x86 family
34 of processors, such as Intel's. Apache may also run on Windows
35 95, 98 and ME, but these are not tested, and are never
36 recommended for production servers. In all cases TCP/IP
37 networking must be installed.</p>
39 <p>If running on Windows 95, the "Winsock2" upgrade MUST BE
40 INSTALLED. "Winsock2" for Windows 95 is available <a href="http://www.microsoft.com/windows95/downloads/">here</a>.</p>
42 <p>If running on NT 4.0, installing Service Pack 3 or 6 is
43 recommended, as Service Pack 4 created known issues with TCP/IP
44 and WinSock integrity that were resolved in later Service
47 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="down" id="down">Downloading Apache for Windows</a></h2>
51 <p>Information on the latest version of Apache can be found on
52 the Apache web server at <a href="http://httpd.apache.org/">http://httpd.apache.org/</a>.
53 This will list the current release, any more recent alpha or
54 beta-test releases, together with details of mirror web and
55 anonymous ftp sites.</p>
57 <p>You should download the version of Apache for Windows with
58 the <code>.msi</code> extension. This is a single Microsoft
59 Installer file containing Apache, ready to install and run.
60 There is a seperate <code>.zip</code> file containing <em>only</em>
61 the source code, to compile Apache yourself with the Microsoft
62 Visual C++ (Visual Studio) tools.</p>
64 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="inst" id="inst">Installing Apache for Windows</a></h2>
68 <p>Run the Apache <code>.msi</code> file you downloaded above.
69 This will ask for:</p>
72 <li>the directory to install Apache into (the default is
73 <code>\Program Files\Apache Group\Apache</code> although you
74 can change this to any other directory)</li>
76 <li>the start menu name (default is "Apache Web Server")</li>
78 <li>the installation type. The "Typical" option installs
79 everything except the source code. The "Minimum" option does
80 not install the manuals or source code. Choose the "Custom"
81 install if you want to install the source code.</li>
84 <p>During the installation, Apache will configure the files in
85 the <code>conf</code> directory for your chosen installation
86 directory. However if any of the files in this directory
87 already exist they will <em>not</em> be overwritten.
88 Instead the new copy of the corresponding file will be left
89 with the extension <code>.default</code>. So, for example, if
90 <code>conf\httpd.conf</code> already exists it will not be
91 altered, but the version which would have been installed will
92 be left in <code>conf\httpd.conf.default</code>. After the
93 installation has finished you should manually check to see what is
94 in new in the <code>.default</code> file, and if necessary
95 update your existing configuration files.</p>
97 <p>Also, if you already have a file called
98 <code>htdocs\index.html</code> then it will not be overwritten
99 (no <code>index.html.default</code> file will be installed
100 either). This should mean it a safe to install Apache over an
101 existing installation (but you will have to stop the existing
102 server running before doing the installation, then start the
103 new one after the installation is finished).</p>
105 <p>After installing Apache, you should edit the configuration
106 files in the <code>conf</code> directory as required. These
107 files will be configured during the install ready for Apache to
108 be run from the directory where it was installed, with the
109 documents served from the subdirectory <code>htdocs</code>.
110 There are lots of other options which should be set before you
111 start really using Apache. However to get started quickly the
112 files should work as installed.</p>
114 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="run" id="run">Running Apache for Windows</a></h2>
118 <p>There are two ways you can run Apache:</p>
121 <li><p>As a <a href="win_service.html#service">"service"</a>
122 (available on Windows NT/2000, or a pseudo-service on Windows
123 95, 98 or ME). This is the best option if you want Apache to
124 automatically start when you machine boots, and to keep
125 Apache running when you log-off.</p></li>
127 <li><p>From a <a href="#cmdline">console window</a>. This MUST
128 be used by any administrator to test before to attempting to
129 run as a service.</p></li>
132 <p>To run Apache from a console window, select the "Start
133 Apache as console app" option from the Start menu (in Apache
134 1.3.4 and earlier, this option was called "Apache Server").
135 This will open a console window and start Apache running inside
136 it. The window will remain active until you stop Apache. To
137 stop Apache running, either select the "Shutdown Apache console
138 app" icon option from the Start menu (this is not available in
139 Apache 1.3.4 or earlier), or see <a href="#signal">Signalling
140 Console Apache when Running</a> for how to control Apache from
141 the command line.</p>
143 <p>If the Apache console window closes immediately (or
144 unexpectedly), run the "Command Prompt" from the Start Menu -
145 Programs list. Change to the folder to which you installed
146 Apache, type the command apache, and read the error message.
147 Then change to the <code>logs</code> folder, and review the
148 <code>error.log</code> file for configuration mistakes.
149 If you accepted the defaults when you installed Apache,
150 the commands would be:</p>
152 <div class="example"><p><code>
154 cd "\program files\apache group\apache" <br />
156 Wait for Apache to exit, or press Ctrl+C <br />
161 <p><strong>Complete the steps above before you proceed
162 to attempt to start Apache as a Window NT/2000
163 service!</strong></p>
165 <p>To start Apache as a service, you first need to install it
166 as a service. Multiple Apache services can be installed, each
167 with a different name and configuration. To install the default
168 Apache service named "Apache", run the "Install Apache as
169 Service (NT only)" option from the Start menu. Once this is
170 done you can start the "Apache" service by opening the Services
171 window (in the Control Panel), selecting Apache, then clicking
172 on Start. Apache will now be running in the background. You can
173 later stop Apache by clicking on Stop. As an alternative to
174 using the Services window, you can start and stop the "Apache"
175 service from the control line with:</p>
177 <div class="example"><p><code>
178 NET START APACHE <br />
182 <p>See <a href="#signalsrv">Signalling Service Apache when
183 Running</a> for more information on installing and controlling
186 <div class="note"><strong>Apache, unlike many other Windows NT/2000 services,
187 logs any errors to its own <code>error.log</code> file in the
188 <code>logs</code> folder within the Apache server root folder.
189 You will <em>not</em> find Apache error details in the Windows
190 NT Event Log.</strong></div>
192 <p>After starting Apache running (either in a console window or
193 as a service) it will be listening to port 80 (unless you
194 changed the <code class="directive"><a href="../mod/mpm_common.html#listen">Listen</a></code> directive in the configuration
195 files). To connect to the server and access the default page,
196 launch a browser and enter this URL:</p>
198 <div class="example"><p><code>
202 <p>This should respond with a welcome page, and a link to the
203 Apache manual. If nothing happens or you get an error, look in
204 the <code>error_log</code> file in the <code>logs</code>
205 directory. If your host isn't connected to the net, you may
206 have to use this URL:</p>
208 <div class="example"><p><code>
212 <p>Once your basic installation is working, you should
213 configure it properly by editing the files in the
214 <code>conf</code> directory. Again, if you change the
215 configuration of the Windows NT/2000 service for Apache, first
216 attempt to start it from the command line to assure that the
217 service starts with no errors.</p>
219 <p>Because Apache <em>CANNOT</em> share the same port with
220 another TCPIP application, you may need to stop or uninstall
221 certain services first. These include (but are not limited to)
222 other web servers, and firewall products such as BlackIce. If
223 you can only start Apache with these services disabled,
224 reconfigure either Apache or the other product so that they do
225 not listen on the same TCPIP ports.</p>
227 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="use" id="use">Configuring Apache for Windows</a></h2>
231 <p>Apache is configured by files in the <code>conf</code>
232 directory. These are the same as files used to configure the
233 Unix version, but there are a few different directives for
234 Apache on Windows. See the <a href="../">Apache
235 documentation</a> for all the available directives.</p>
237 <p>The main differences in Apache for Windows are:</p>
241 <p>Because Apache for Windows is multithreaded, it does not
242 use a separate process for each request, as Apache does
243 with Unix. Instead there are usually only two Apache
244 processes running: a parent process, and a child which
245 handles the requests. Within the child each request is
246 handled by a separate thread.</p>
248 <p>So the "process"-management directives are
251 <p><code class="directive"><a href="../mod/mpm_common.html#maxrequestsperchild">MaxRequestsPerChild</a></code>
252 - Like the Unix directive, this controls how many requests
253 a process will serve before exiting. However, unlike Unix,
254 a process serves all the requests at once, not just one, so
255 if this is set, it is recommended that a very high number
256 is used. The recommended default, <code>MaxRequestsPerChild
257 0</code>, does not cause the process to ever exit.</p>
259 <div class="warning"><strong>Warning: The server configuration
260 file is reread when the new child process is started. If you
261 have modified <code>httpd.conf</code>, the new child may not
262 start or you may receive unexpected results.</strong></div>
264 <p><code class="directive"><a href="../mod/mpm_common.html#threadsperchild">ThreadsPerChild</a></code>
265 - This directive is new, and tells the server how many
266 threads it should use. This is the maximum number of
267 connections the server can handle at once; be sure and set
268 this number high enough for your site if you get a lot of
269 hits. The recommended default is <code>ThreadsPerChild
274 <p>The directives that accept filenames as arguments now
275 must use Windows filenames instead of Unix ones. However,
276 because Apache uses Unix-style names internally, you must
277 use forward slashes, not backslashes. Drive letters can be
278 used; if omitted, the drive with the Apache executable will
283 <p>Apache for Windows contains the ability to load modules
284 at runtime, without recompiling the server. If Apache is
285 compiled normally, it will install a number of optional
286 modules in the <code>\Apache\modules</code> directory. To
287 activate these, or other modules, the new <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code>
288 directive must be used. For example, to active the status
289 module, use the following (in addition to the
290 status-activating directives in
291 <code>access.conf</code>):</p>
293 <div class="example"><p><code>
294 LoadModule status_module modules/mod_status.so
297 <p>Information on <a href="../mod/mod_so.html#creating">creating loadable
298 modules</a> is also available.</p>
302 <p>Apache can also load ISAPI Extensions (<em>i.e.</em>,
303 Internet Server Applications), such as those used by
304 Microsoft's IIS, and other Windows servers. <a href="../mod/mod_isapi.html">More information is
305 available.</a> Note that Apache <em>CANNOT</em> load ISAPI
310 <p>When running CGI scripts, the method Apache uses to find
311 the interpreter for the script is configurable using the
312 <code class="directive"><a href="../mod/mod_core.html#scriptinterpretersource">ScriptInterpreterSource</a></code>
317 <p>Since it is often difficult to manage files with names
318 like <code>.htaccess</code> under windows, you may find it
319 useful to change the name of this configuration file using
320 the <code class="directive"><a href="../mod/mod_core.html#accessfilename">AccessFilename</a></code>
325 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="service" id="service">Running Apache for Windows as a Service</a></h2>
329 <div class="note"><strong>The <code>-n</code> option to specify a service name
330 is only available with Apache 1.3.7 and later. Earlier versions of
331 Apache only support the default service name
332 "Apache".</strong></div>
334 <p>You can install Apache as a Windows NT service as
337 <div class="example"><p><code>
338 apache -k install -n "service name"
341 <p>To install a service to use a particular configuration,
342 specify the configuration file when the service is
345 <div class="example"><p><code>
346 apache -k install -n "service name" -f "\my server\conf\my.conf"
349 <p>To remove an Apache service, use</p>
351 <div class="example"><p><code>
352 apache -k uninstall -n "service name"
355 <p>The default "service name", if one is not specified, is
358 <p>Once a service is installed, you can use the <code>-n</code>
359 option, in conjunction with other options, to refer to a
360 service's configuration file. For example:</p>
362 <p>To test a service's configuration file:</p>
364 <div class="example"><p><code>
365 apache -n "service name" -t
368 <p>To start a console Apache using a service's configuration
371 <div class="example"><p><code>
372 apache -n "service name"
375 <p><strong>Important Note on service dependencies:</strong></p>
377 <p>Prior to Apache release 1.3.13, the dependencies required to
378 successfully start an installed service were not configured.
379 After installing a service using earlier versions of Apache,
380 you must follow these steps:</p>
382 <div class="example"><p><code>
384 Select Window - "HKEY_LOCAL_MACHINE on Local Machine" from the menu <br />
385 Double-click to open the SYSTEM, then the CurrentControlSet keys <br />
386 Scroll down and click on the Apache servicename <br />
387 Select Edit - Add Value... from the menu <br />
388 Fill in the Add Value dialog with <br />
389 Value Name: DependOnGroup <br />
390 Data Type: REG_MULTI_SZ <br />
392 Leave the Multi-String Editor dialog empty and click OK <br />
393 Select Edit - Add Value... from the menu <br />
394 Fill in the Add Value dialog with <br />
395 Value Name: DependOnService <br />
396 Data Type: REG_MULTI_SZ <br />
398 Type the following list (one per line) in the Multi-String Editor dialog <br />
404 <p>If you are using COM or DCOM components from a third party
405 module, ISAPI, or other add-in scripting technologies such as
406 ActiveState Perl, you may also need to add the entry Rpcss to
407 the DependOnService list. To avoid exposing the TCP port 135
408 when it is unnecessary, Apache does not create that entry upon
409 installation. Follow the directions above to find or create the
410 DependOnService value, double click that value if it already
411 exists, and add the Rpcss entry to the list.</p>
413 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="cmdline" id="cmdline">Running Apache for Windows from the Command Line</a></h2>
417 <p>The Start menu icons and the NT Service manager can provide
418 a simple interface for administering Apache. But in some cases
419 it is easier to work from the command line.</p>
421 <p>When working with Apache it is important to know how it will
422 find the configuration files. You can specify a configuration
423 file on the command line in two ways:</p>
426 <li><code>-f</code> specifies a path to a particular
427 configuration file</li>
430 <div class="example"><p><code>
431 apache -f "c:\my server\conf\my.conf" <br />
432 apache -f test\test.conf
436 <li><code>-n</code> specifies the configuration file of
437 an installed Apache service (Apache 1.3.7 and later)</li>
440 <div class="example"><p><code>
441 apache -n "service name"
444 <p>In these cases, the proper <code class="directive"><a href="../mod/mod_core.html#serverroot">ServerRoot</a></code> should be set in the configuration file.</p>
446 <p>If you don't specify a configuration file name with <code>-f</code> or
447 <code>-n</code>, Apache will use the file name compiled into the server,
448 usually "<code>conf/httpd.conf</code>". Invoking Apache with the
449 <code>-V</code> switch will display this value labeled as
450 <code>SERVER_CONFIG_FILE</code>. Apache
451 will then determine its <code class="directive"><a href="../mod/mod_core.html#serverroot">ServerRoot</a></code> by trying the following, in
455 <li>A <code>ServerRoot</code> directive via a
456 <code>-C</code> switch.</li>
458 <li>The <code>-d</code> switch on the command line.</li>
460 <li>Current working directory</li>
462 <li>A registry entry, created if you did a binary
465 <li>The server root compiled into the server.</li>
468 <p>The server root compiled into the server is usually
469 "<code>/apache</code>". invoking apache with the <code>-V</code> switch
470 will display this value labeled as <code>HTTPD_ROOT</code>.</p>
472 <p>When invoked from the start menu, Apache is usually passed
473 no arguments, so using the registry entry is the preferred
474 technique for console Apache.</p>
476 <p>During a binary installation, a version-specific registry
477 key is created in the Windows registry:</p>
479 <div class="example"><p><code>
480 HKEY_LOCAL_MACHINE\Software\Apache Group\Apache\1.3.7 <br />
482 HKEY_LOCAL_MACHINE\Software\Apache Group\Apache\2.0a3
485 <p>This key is compiled into the server and can enable you to
486 test new versions without affecting the current version. Of
487 course you must take care not to install the new version on top
488 of the old version in the file system.</p>
490 <p>If you did not do a binary install then Apache will in some
491 scenarios complain that about the missing registry key. This
492 warning can be ignored if it otherwise was able to find its
493 configuration files.</p>
495 <p>The value of this key is the <code class="directive"><a href="../mod/mod_core.html#serverroot">ServerRoot</a></code> directory, containing the <code>conf</code>
496 directory. When Apache starts it will read the <code>httpd.conf</code>
497 file from this directory. If this file contains a
498 <code class="directive"><a href="../mod/mod_core.html#serverroot">ServerRoot</a></code> directive which
499 is different from the directory obtained from the registry key above,
500 Apache will forget the registry key and use the directory from the
501 configuration file. If you copy the Apache directory or configuration
502 files to a new location it is vital that you update the
503 <code class="directive"><a href="../mod/mod_core.html#serverroot">ServerRoot</a></code> directory
504 in the <code>httpd.conf</code> file to the new location.</p>
506 <p>To run Apache from the command line as a console
507 application, use the following command:</p>
509 <div class="example"><p><code>
513 <p>Apache will execute, and will remain running until it is
514 stopped by pressing control-C.</p>
516 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="signalsrv" id="signalsrv">Signalling Service Apache when running</a></h2>
520 <p>On Windows NT, multiple instances of Apache can be run as
521 services. Signal an Apache service to start, restart, or
522 shutdown as follows:</p>
524 <div class="example"><p><code>
525 apache -n "service name" -k start <br />
526 apache -n "service name" -k restart <br />
527 apache -n "service name" -k shutdown
530 <p>In addition, you can use the native NT <code>NET</code> command
531 to start and stop Apache services as follows:</p>
533 <div class="example"><p><code>
534 NET START "service name" <br />
535 NET STOP "service name"
538 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="signal" id="signal">Signalling Console Apache when running</a></h2>
542 <p>On Windows 95, Apache runs as a console application. You can
543 tell a running Apache to stop by opening another console window
546 <div class="example"><p><code>
550 <p>This should be used instead of pressing Control-C in the
551 running Apache console window, because it lets Apache end any
552 current transactions and cleanup gracefully.</p>
554 <p>You can also tell Apache to restart. This makes it re-read
555 the configuration files. Any transactions in progress are
556 allowed to complete without interruption. To restart Apache,
559 <div class="example"><p><code>
563 <div class="note">Note for people familiar with the Unix version of Apache:
564 these commands provide a Windows equivalent to <code>kill -TERM
565 <em>pid</em></code> and <code>kill -USR1 <em>pid</em></code>.
566 The command line option used, <code>-k</code>, was chosen as a
567 reminder of the "<code>kill</code>" command used on Unix.</div>
569 </div></div><div id="footer"><p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p><p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div></body></html>