1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <manualpage metafile="windows.xml.meta">
24 <parentdocument href="./">Platform Specific Notes</parentdocument>
26 <title>Using Apache HTTP Server on Microsoft Windows</title>
29 <p>This document explains how to install, configure and run
30 Apache 2.3 under Microsoft Windows. If you have questions after
31 reviewing the documentation (and any event and error logs), you
32 should consult the peer-supported
33 <a href="http://httpd.apache.org/userslist.html">users' mailing
36 <p>This document assumes that you are installing a binary
37 distribution of Apache. If you want to compile Apache yourself
38 (possibly to help with development or tracking down bugs),
39 see <a href="win_compiling.html">Compiling Apache for Microsoft
44 <title>Operating System Requirements</title>
46 <p>The primary Windows platform for running Apache 2.3 is Windows
47 2000 or later. The binary installer only works with the x86 family
48 of processors, such as Intel and AMD processors. Always obtain and
49 install the current service pack to avoid operating system bugs.</p>
51 <note>Apache HTTP Server versions later than 2.2 will not run on any
52 operating system earlier than Windows 2000.</note>
56 <title>Downloading Apache for Windows</title>
58 <p>Information on the latest versions of Apache can be found on the
59 web site of the Apache web server at
60 <a href="http://httpd.apache.org/download.cgi">http://httpd.apache.org/download.cgi</a>.
61 There you will find the current release, as well as more recent alpha
62 or beta test versions, and a list of HTTP and FTP mirrors from which
63 you can download the Apache web server. Please use a mirror near to
64 you for a fast and reliable download.</p>
66 <p>For Windows installations you should download the version of
67 Apache for Windows with the <code>.msi</code> extension. This is a
68 single Microsoft Installer file, which contains a ready-to-run
69 build of Apache. There is a separate <code>.zip</code> file,
70 which contains only the source code, see the summary above.</p>
74 <title>Installing Apache for Windows</title>
76 <p>You need Microsoft Installer 2.0 or above for the installation
77 to work. For Windows NT 4.0 and 2000 refer to Microsoft's article
78 <a href="http://support.microsoft.com/kb/292539/">KB 292539</a>.
79 Windows XP and later do not require this update.</p>
81 <p>Note that you cannot install two versions of Apache 2.3 on the
82 same computer with the binary installer. You can, however, install
83 a version of the 1.3 series <strong>and</strong> a version of the
84 2.3 series on the same computer without problems. If you need to
85 have two different 2.3 versions on the same computer, you have to
86 <a href="win_compiling.html">compile and install Apache from the
89 <p>Run the Apache <code>.msi</code> file you downloaded above. The
90 installation will ask you for these things:</p>
93 <li><p><strong>Network Domain.</strong> Enter the DNS domain in which
94 your server is or will be registered in. For example, if your
95 server's full DNS name is <code>server.mydomain.net</code>, you would
96 type <code>mydomain.net</code> here.</p></li>
98 <li><p><strong>Server Name.</strong> Your server's full DNS name.
99 From the example above, you would type <code>server.mydomain.net</code>
102 <li><p><strong>Administrator's Email Address.</strong> Enter the
103 server administrator's or webmaster's email address here. This
104 address will be displayed along with error messages to the client
107 <li><p><strong>For whom to install Apache</strong> Select <code>for
108 All Users, on Port 80, as a Service - Recommended</code> if you'd
109 like your new Apache to listen at port 80 for incoming traffic.
110 It will run as a service (that is, Apache will run even if no one
111 is logged in on the server at the moment) Select <code>only for
112 the Current User, on Port 8080, when started Manually</code> if
113 you'd like to install Apache for your personal experimenting or
114 if you already have another WWW server running on port 80.</p></li>
116 <li><p><strong>The installation type.</strong> Select <code>Typical</code>
117 for everything except the source code and libraries for module
118 development. With <code>Custom</code> you can specify what to
119 install. A full install will require about 13 megabytes of free
120 disk space. This does <em>not</em> include the size of your web
123 <li><p><strong>Where to install.</strong> The default path is
124 <code>C:\Program Files\Apache Software Foundation</code>
125 under which a directory called
126 <code>Apache2.3</code> will be created by default.</p></li>
129 <p>During the installation, Apache will configure the files in the
130 <code>conf</code> subdirectory to reflect the chosen installation
131 directory. However, if any of the configuration files in this
132 directory already exist, they will not be overwritten. Instead, the
133 new copy of the corresponding file will be left with the extension
134 <code>.default</code>. So, for example, if <code>conf\httpd.conf</code>
135 already exists, it will be renamed as <code>conf\httpd.conf.default</code>.
136 After the installation you should manually check to see what new
137 settings are in the <code>.default</code> file, and if necessary,
138 update your existing configuration file.</p>
140 <p>Also, if you already have a file called <code>htdocs\index.html</code>,
141 it will not be overwritten (and no <code>index.html.default</code>
142 will be installed either). This means it should be safe to install
143 Apache over an existing installation, although you would have to
144 stop the existing running server before doing the installation, and
145 then start the new one after the installation is finished.</p>
147 <p>After installing Apache, you must edit the configuration files
148 in the <code>conf</code> subdirectory as required. These files
149 will be configured during the installation so that Apache is ready
150 to be run from the directory it was installed into, with the
151 documents server from the subdirectory <code>htdocs</code>. There
152 are lots of other options which you should set before you really
153 start using Apache. However, to get started quickly, the files
154 should work as installed.</p>
158 <title>Customizing Apache for Windows</title>
160 <p>Apache is configured by the files in the <code>conf</code>
161 subdirectory. These are the same files used to configure the Unix
162 version, but there are a few different directives for Apache on
163 Windows. See the <a href="../mod/directives.html">directive index</a>
164 for all the available directives.</p>
166 <p>The main differences in Apache for Windows are:</p>
168 <li><p>Because Apache for Windows is multithreaded, it does not
169 use a separate process for each request, as Apache can on Unix.
170 Instead there are usually only two Apache processes running: a
171 parent process, and a child which handles the requests. Within
172 the child process each request is handled by a separate thread.
175 <p>The process management directives are also different:</p>
177 <p><directive module="mpm_common">MaxRequestsPerChild</directive>:
178 Like the Unix directive, this controls how many requests (actually,
179 connections) which a single child process will serve before exiting.
180 However, unlike on Unix, a replacement process is not instantly
181 available. Use the default <code>MaxRequestsPerChild 0</code>,
182 unless instructed to change the behavior to overcome a memory leak
183 in third party modules or in-process applications.</p>
185 <note type="warning"><strong>Warning: The server configuration
186 file is reread when a new child process is started. If you have
187 modified <code>httpd.conf</code>, the new child may not start or
188 you may receive unexpected results.</strong></note>
190 <p><directive module="mpm_common">ThreadsPerChild</directive>:
191 This directive is new. It tells the server how many threads it
192 should use. This is the maximum number of connections the server
193 can handle at once, so be sure to set this number high enough for
194 your site if you get a lot of hits. The recommended default is
195 <code>ThreadsPerChild 150</code>, but this must be adjusted to
196 reflect the greatest anticipated number of simultanious
197 connections to accept.</p></li>
199 <li><p>The directives that accept filenames as arguments must use
200 Windows filenames instead of Unix ones. However, because Apache
201 may interpret backslashes as an "escape character" sequence, you
202 should consistently use forward slashes in path names, not
203 backslashes. Drive letters can be used; if omitted, the drive
204 of the SystemRoot directive (or -d command line option) becomes
205 the default.</p></li>
207 <li><p>While filenames are generally case-insensitive on
208 Windows, URLs are still treated internally as case-sensitive
209 before they are mapped to the filesystem. For example, the
210 <directive module="core" type="section">Location</directive>,
211 <directive module="mod_alias">Alias</directive>, and <directive
212 module="mod_proxy">ProxyPass</directive> directives all use
213 case-sensitive arguments. For this reason, it is particularly
214 important to use the <directive module="core"
215 type="section">Directory</directive> directive when attempting
216 to limit access to content in the filesystem, since this
217 directive applies to any content in a directory, regardless of
218 how it is accessed. If you wish to assure that only lowercase
219 is used in URLs, you can use something like:</p>
222 RewriteEngine On<br />
223 RewriteMap lowercase int:tolower<br />
224 RewriteCond %{REQUEST_URI} [A-Z]<br />
225 RewriteRule (.*) ${lowercase:$1} [R,L]
228 <li><p>When running, Apache needs write access only to the logs
229 directory and any configured cache directory tree. Due to the
230 issue of case insensitive and short 8.3 format names, Apache must
231 validate all path names given. This means that each directory
232 which Apache evaluates, from the drive root up to the directory
233 leaf, must have read, list and traverse directory permissions.
234 If Apache2.3 is installed at C:\Program Files, then the root
235 directory, Program Files and Apache2.3 must all be visible
238 <li><p>Apache for Windows contains the ability to load modules at
239 runtime, without recompiling the server. If Apache is compiled
240 normally, it will install a number of optional modules in the
241 <code>\Apache2.3\modules</code> directory. To activate these or
242 other modules, the new <directive module="mod_so">LoadModule</directive>
243 directive must be used. For example, to activate the status
244 module, use the following (in addition to the status-activating
245 directives in <code>access.conf</code>):</p>
248 LoadModule status_module modules/mod_status.so
251 <p>Information on <a href="../mod/mod_so.html#creating">creating
252 loadable modules</a> is also available.</p></li>
254 <li><p>Apache can also load ISAPI (Internet Server Application
255 Programming Interface) extensions such as those used by Microsoft
256 IIS and other Windows servers. <a href="../mod/mod_isapi.html">More
257 information is available</a>. Note that Apache <strong>cannot</strong>
258 load ISAPI Filters, and ISAPI Handlers with some Microsoft feature
259 extensions will not work.</p></li>
261 <li><p>When running CGI scripts, the method Apache uses to find
262 the interpreter for the script is configurable using the
263 <directive module="core">ScriptInterpreterSource</directive>
266 <li><p>Since it is often difficult to manage files with names
267 like <code>.htaccess</code> in Windows, you may find it useful to
268 change the name of this per-directory configuration file using
269 the <directive module="core">AccessFilename</directive>
272 <li><p>Any errors during Apache startup are logged into the
273 Windows event log when running on Windows NT. This mechanism
274 acts as a backup for those situations where Apache is not yet
275 prepared to use the <code>error.log</code> file. You can
276 review the Windows Applicat Event Log by using the Event Viewer,
277 e.g. Start - Settings - Control Panel - Administrative Tools
278 - Event Viewer.</p></li>
283 <section id="winsvc">
284 <title>Running Apache as a Service</title>
286 <p>You can install Apache as a service automatically during the
287 installation. If you chose to install for all users, the
288 installation will create an Apache service for you. If you specify
289 to install for yourself only, you can manually register Apache as a
290 service after the installation. You have to be a member of the
291 Administrators group for the service installation to succeed.</p>
293 <p>Apache comes with a utility called the Apache Service Monitor.
294 With it you can see and manage the state of all installed Apache
295 services on any machine on your network. To be able to manage an
296 Apache service with the monitor, you have to first install the
297 service (either automatically via the installation or manually).
300 <p>You can install Apache as a Windows NT service as follows from
301 the command prompt at the Apache <code>bin</code> subdirectory:</p>
307 <p>If you need to specify the name of the service you want to
308 install, use the following command. You have to do this if you
309 have several different service installations of Apache on your
313 httpd.exe -k install -n "MyServiceName"
316 <p>If you need to have specifically named configuration files for
317 different services, you must use this:</p>
320 httpd.exe -k install -n "MyServiceName" -f "c:\files\my.conf"
323 <p>If you use the first command without any special parameters except
324 <code>-k install</code>, the service will be called <code>Apache2.3</code>
325 and the configuration will be assumed to be <code>conf\httpd.conf</code>.
328 <p>Removing an Apache service is easy. Just use:</p>
331 httpd.exe -k uninstall
334 <p>The specific Apache service to be uninstalled can be specified by using:</p>
337 httpd.exe -k uninstall -n "MyServiceName"
340 <p>Normal starting, restarting and shutting down of an Apache
341 service is usually done via the Apache Service Monitor, by using
342 commands like <code>NET START Apache2.3</code> and <code>NET STOP
343 Apache2.3</code> or via normal Windows service management. Before
344 starting Apache as a service by any means, you should test the
345 service's configuration file by using:</p>
348 httpd.exe -n "MyServiceName" -t
351 <p>You can control an Apache service by its command line switches,
352 too. To start an installed Apache service you'll use this:</p>
358 <p>To stop an Apache service via the command line switches, use
368 httpd.exe -k shutdown
371 <p>You can also restart a running service and force it to reread
372 its configuration file by using:</p>
378 <p>By default, all Apache services are registered to run as the
379 system user (the <code>LocalSystem</code> account). The
380 <code>LocalSystem</code> account has no privileges to your network
381 via any Windows-secured mechanism, including the file system, named
382 pipes, DCOM, or secure RPC. It has, however, wide privileges locally.
385 <note type="warning"><strong>Never grant any network privileges to
386 the <code>LocalSystem</code> account! If you need Apache to be able
387 to access network resources, create a separate account for Apache as
388 noted below.</strong></note>
390 <p>It is recommended that users create a separate account for running
391 Apache service(s). If you have to access network resources via Apache,
392 this is required.</p>
395 <li>Create a normal domain user account, and be sure to
396 memorize its password.</li>
398 <li>Grant the newly-created user a privilege of <code>Log on
399 as a service</code> and <code>Act as part of the operating
400 system</code>. On Windows NT 4.0 these privileges are granted via
401 User Manager for Domains, but on Windows 2000 and XP you probably
402 want to use Group Policy for propagating these settings. You can
403 also manually set these via the Local Security Policy MMC snap-in.
406 <li>Confirm that the created account is a member of the Users
409 <li>Grant the account read and execute (RX) rights to all document
410 and script folders (<code>htdocs</code> and <code>cgi-bin</code>
413 <li>Grant the account change (RWXD) rights to the
414 Apache <code>logs</code> directory.</li>
416 <li>Grant the account read and execute (RX) rights to the
417 <code>httpd.exe</code> binary executable.</li>
420 <note>It is usually a good practice to grant the user the Apache
421 service runs as read and execute (RX) access to the whole Apache2.3
422 directory, except the <code>logs</code> subdirectory, where the
423 user has to have at least change (RWXD) rights.</note>
425 <p>If you allow the account to log in as a user and as a service,
426 then you can log on with that account and test that the account has
427 the privileges to execute the scripts, read the web pages, and that
428 you can start Apache in a console window. If this works, and you
429 have followed the steps above, Apache should execute as a service
430 with no problems.</p>
432 <note><strong>Error code 2186</strong> is a good indication that
433 you need to review the "Log On As" configuration for the service,
434 since Apache cannot access a required network resource. Also, pay
435 close attention to the privileges of the user Apache is
436 configured to run as.</note>
438 <p>When starting Apache as a service you may encounter an error
439 message from the Windows Service Control Manager. For example,
440 if you try to start Apache by using the Services applet in the
441 Windows Control Panel, you may get the following message:</p>
444 Could not start the Apache2.3 service on \\COMPUTER <br />
445 Error 1067; The process terminated unexpectedly.
448 <p>You will get this generic error if there is any problem with
449 starting the Apache service. In order to see what is really causing
450 the problem you should follow the instructions for Running Apache
451 for Windows from the Command Prompt.</p>
453 <p>If you are having problems with the service, it is suggested
454 you follow the instructions below to try starting httpd.exe from
455 a console window, and work out the errors before struggling to
456 start it as a service again.</p>
459 <section id="wincons">
460 <title>Running Apache as a Console Application</title>
462 <p>Running Apache as a service is usually the recommended way to
463 use it, but it is sometimes easier to work from the command line,
464 especially during initial configuration and testing.</p>
466 <p>To run Apache from the command line as a console application,
467 use the following command:</p>
473 <p>Apache will execute, and will remain running until it is stopped
474 by pressing Control-C.</p>
476 <p>You can also run Apache via the shortcut Start Apache in Console
477 placed to <code>Start Menu --> Programs --> Apache HTTP Server
478 2.3.xx --> Control Apache Server</code> during the installation.
479 This will open a console window and start Apache inside it. If you
480 don't have Apache installed as a service, the window will remain
481 visible until you stop Apache by pressing Control-C in the console
482 window where Apache is running in. The server will exit in a few
483 seconds. However, if you do have Apache installed as a service, the
484 shortcut starts the service. If the Apache service is running
485 already, the shortcut doesn't do anything.</p>
487 <p>You can tell a running Apache to stop by opening another console
488 window and entering:</p>
491 httpd.exe -k shutdown
494 <p>This should be preferred over pressing Control-C because this
495 lets Apache end any current operations and clean up gracefully.</p>
497 <p>You can also tell Apache to restart. This forces it to reread
498 the configuration file. Any operations in progress are allowed to
499 complete without interruption. To restart Apache, either press
500 Control-Break in the console window you used for starting Apache,
507 <p>in any other console window.</p>
509 <note>Note for people familiar with the Unix version of Apache:
510 these commands provide a Windows equivalent to <code>kill -TERM
511 <em>pid</em></code> and <code>kill -USR1 <em>pid</em></code>. The
512 command line option used, <code>-k</code>, was chosen as a reminder
513 of the <code>kill</code> command used on Unix.</note>
515 <p>If the Apache console window closes immediately or unexpectedly
516 after startup, open the Command Prompt from the Start Menu -->
517 Programs. Change to the folder to which you installed Apache, type
518 the command <code>httpd.exe</code>, and read the error message. Then
519 change to the logs folder, and review the <code>error.log</code>
520 file for configuration mistakes. If you accepted the defaults when
521 you installed Apache, the commands would be:</p>
525 cd "\Program Files\Apache Software Foundation\Apache2.3\bin" <br />
529 <p>Then wait for Apache to stop, or press Control-C. Then enter the
537 <p>When working with Apache it is important to know how it will
538 find the configuration file. You can specify a configuration file
539 on the command line in two ways:</p>
542 <li><p><code>-f</code> specifies an absolute or relative path to
543 a particular configuration file:</p>
546 httpd.exe -f "c:\my server files\anotherconfig.conf"
552 httpd.exe -f files\anotherconfig.conf
555 <li><p><code>-n</code> specifies the installed Apache service
556 whose configuration file is to be used:</p>
559 httpd.exe -n "MyServiceName"
564 <p>In both of these cases, the proper
565 <directive module="core">ServerRoot</directive> should be set in
566 the configuration file.</p>
568 <p>If you don't specify a configuration file with <code>-f</code>
569 or <code>-n</code>, Apache will use the file name compiled into the
570 server, such as <code>conf\httpd.conf</code>. This built-in path
571 is relative to the installation directory. You can verify the compiled
572 file name from a value labelled as <code>SERVER_CONFIG_FILE</code> when
573 invoking Apache with the <code>-V</code> switch, like this:</p>
579 <p>Apache will then try to determine its <directive module="core"
580 >ServerRoot</directive> by trying the following, in this order:</p>
583 <li>A <directive module="core">ServerRoot</directive> directive
584 via the <code>-C</code> command line switch.</li>
586 <li>The <code>-d</code> switch on the command line.</li>
588 <li>Current working directory.</li>
590 <li>A registry entry which was created if you did a binary
593 <li>The server root compiled into the server. This is <code>
594 /apache</code> by default, you can verify it by using <code>
595 httpd.exe -V</code> and looking for a value labelled as
596 <code>HTTPD_ROOT</code>.</li>
599 <p>During the installation, a version-specific registry key is
600 created in the Windows registry. The location of this key depends
601 on the type of the installation. If you chose to install Apache
602 for all users, the key is located under the
603 <code>HKEY_LOCAL_MACHINE</code> hive, like this (the version
604 numbers will of course vary between different versions of Apache:
608 HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Apache\2.2.2
611 <p>Correspondingly, if you chose to install Apache for the current
612 user only, the key is located under the <code>HKEY_CURRENT_USER</code>
613 hive, the contents of which are dependent of the user currently
617 HKEY_CURRENT_USER\SOFTWARE\Apache Software Foundation\Apache\2.2.2
620 <p>This key is compiled into the server and can enable you to test
621 new versions without affecting the current version. Of course, you
622 must take care not to install the new version in the same
623 directory as another version.</p>
625 <p>If you did not do a binary install, Apache will in some
626 scenarios complain about the missing registry key. This warning can
627 be ignored if the server was otherwise able to find its
628 configuration file.</p>
630 <p>The value of this key is the
631 <directive module="core">ServerRoot</directive> directory which
632 contains the <code>conf</code> subdirectory. When Apache starts it
633 reads the <code>httpd.conf</code> file from that directory. If
634 this file contains a <directive module="core">ServerRoot</directive>
635 directive which contains a different directory from the one
636 obtained from the registry key above, Apache will forget the
637 registry key and use the directory from the configuration file. If
638 you copy the Apache directory or configuration files to a new
639 location it is vital that you update the
640 <directive module="core">ServerRoot</directive> directive in the
641 <code>httpd.conf</code> file to reflect the new location.</p>
645 <title>Testing the Installation</title>
647 <p>After starting Apache (either in a console window or as a
648 service) it will be listening on port 80 (unless you changed the
649 <directive module="mpm_common">Listen</directive> directive in the
650 configuration files or installed Apache only for the current user).
651 To connect to the server and access the default page, launch a
652 browser and enter this URL:</p>
658 <p>Apache should respond with a welcome page and you should see
659 "It Works!". If nothing happens or you get an error, look in the
660 <code>error.log</code> file in the <code>logs</code> subdirectory.
661 If your host is not connected to the net, or if you have serious
662 problems with your DNS (Domain Name Service) configuration, you
663 may have to use this URL:</p>
669 <p>If you happen to be running Apache on an alternate port, you
670 need to explicitly put that in the URL:</p>
673 http://127.0.0.1:8080/
676 <p>Once your basic installation is working, you should configure it
677 properly by editing the files in the <code>conf</code> subdirectory.
678 Again, if you change the configuration of the Windows NT service
679 for Apache, first attempt to start it from the command line to
680 make sure that the service starts with no errors.</p>
682 <p>Because Apache <strong>cannot</strong> share the same port with
683 another TCP/IP application, you may need to stop, uninstall or reconfigure
684 certain other services before running Apache. These conflicting
685 services include other WWW servers, some firewall implementations,
686 and even some client applications (such as Skype) which will use port
687 80 to attempt to bypass firewall issues.</p>