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      -->
8<title>Using Apache HTTP Server on Microsoft Windows - Apache HTTP Server</title>
9<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
12<script src="/style/scripts/prettify.js" type="text/javascript">
13</script>
14
15<link href="/images/favicon.ico" rel="shortcut icon" /></head>
16<body id="manual-page"><div id="page-header">
17<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
18<p class="apache">Apache HTTP Server Version 2.2</p>
19<img alt="" src="/images/feather.gif" /></div>
20<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
21<div id="path">
22<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.2</a> &gt; <a href="./">Platform Specific Notes</a></div><div id="page-content"><div id="preamble"><h1>Using Apache HTTP Server on Microsoft Windows</h1>
23<div class="toplang">
24<p><span>Available Languages: </span><a href="/en/platform/windows.html" title="English">&nbsp;en&nbsp;</a> |
25<a href="/ko/platform/windows.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
26</div>
27
28    <p>This document explains how to install, configure and run
29    Apache 2.2 under Microsoft Windows.  If you have questions after
30    reviewing the documentation (and any event and error logs), you
31    should consult the peer-supported 
32    <a href="http://httpd.apache.org/userslist.html">users' mailing
33    list</a>.</p>
34
35    <p>This document assumes that you are installing a binary
36    distribution of Apache. If you want to compile Apache yourself
37    (possibly to help with development or tracking down bugs),
38    see <a href="win_compiling.html">Compiling Apache for Microsoft
39    Windows</a>.</p>
40  </div>
41<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#req">Operating System Requirements</a></li>
42<li><img alt="" src="/images/down.gif" /> <a href="#down">Downloading Apache for Windows</a></li>
43<li><img alt="" src="/images/down.gif" /> <a href="#inst">Installing Apache for Windows</a></li>
44<li><img alt="" src="/images/down.gif" /> <a href="#advinst">Advanced Installation Topics</a></li>
45<li><img alt="" src="/images/down.gif" /> <a href="#cust">Customizing Apache for Windows</a></li>
46<li><img alt="" src="/images/down.gif" /> <a href="#winsvc">Running Apache as a Service</a></li>
47<li><img alt="" src="/images/down.gif" /> <a href="#wincons">Running Apache as a Console Application</a></li>
48<li><img alt="" src="/images/down.gif" /> <a href="#test">Testing the Installation</a></li>
49<li><img alt="" src="/images/down.gif" /> <a href="#windrivemap">Configuring Access to Network Resources</a></li>
50</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
51<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
52<div class="section">
53<h2><a name="req" id="req">Operating System Requirements</a></h2>
54    
55
56    <p>The primary Windows platform for running Apache 2.2 is Windows
57    2000 or later.  The binary installer only works with the x86 family
58    of processors, such as Intel and AMD processors.  Always obtain and
59    install the current service pack to avoid operating system bugs.</p>
60
61    <div class="note">Running Apache on Windows 9x is ignored by the developers, and
62    is strongly discouraged.  On Windows NT 4.0, installing Service
63    Pack 6 is required.  Apache HTTP Server versions later than 2.2 will
64    not run on any operating system earlier than Windows 2000.</div>
65  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
66<div class="section">
67<h2><a name="down" id="down">Downloading Apache for Windows</a></h2>
68    
69
70    <p>Information on the latest versions of Apache can be found on the
71    web site of the Apache web server at
72    <a href="http://httpd.apache.org/download.cgi">http://httpd.apache.org/download.cgi</a>.
73    There you will find the current release, as well as more recent alpha
74    or beta test versions, and a list of HTTP and FTP mirrors from which
75    you can download the Apache web server. Please use a mirror near to
76    you for a fast and reliable download.</p>
77
78    <p>For Windows installations you should download the version of
79    Apache for Windows with the <code>.msi</code> extension. This is a
80    single Microsoft Installer file, which contains a ready-to-run
81    build of Apache.  There is a separate <code>.zip</code> file,
82    which contains only the source code, see the summary above.</p>
83  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
84<div class="section">
85<h2><a name="inst" id="inst">Installing Apache for Windows</a></h2>
86    
87
88    <p>You need Microsoft Installer 2.0 or above for the installation
89    to work.  For Windows NT 4.0 and 2000 refer to Microsoft's article
90    <a href="http://support.microsoft.com/kb/292539/">KB 292539</a>.
91    Windows XP and later do not require this update.  The Windows 98/ME
92    installer engine appears to no longer be available from Microsoft,
93    and these instructions no longer detail such prerequisites.</p>
94
95    <p>Note that you cannot install two versions of Apache 2.2 on the
96    same computer with the binary installer. You can, however, install
97    a version of the 1.3 series <strong>and</strong> a version of the
98    2.2 series on the same computer without problems. If you need to
99    have two different 2.2 versions on the same computer, you have to
100    <a href="win_compiling.html">compile and install Apache from the
101    source</a>.</p>
102
103    <p>Run the Apache <code>.msi</code> file you downloaded above. The
104    installation will ask you for these things:</p>
105
106    <ol>
107      <li><p><strong>Network Domain.</strong> Enter the DNS domain in which
108      your server is or will be registered in. For example, if your
109      server's full DNS name is <code>server.mydomain.net</code>, you would
110      type <code>mydomain.net</code> here.</p></li>
111
112      <li><p><strong>Server Name.</strong> Your server's full DNS name.
113      From the example above, you would type <code>server.mydomain.net</code>
114      here.</p></li>
115
116      <li><p><strong>Administrator's Email Address.</strong> Enter the
117      server administrator's or webmaster's email address here. This
118      address will be displayed along with error messages to the client
119      by default.</p></li>
120
121      <li><p><strong>For whom to install Apache</strong> Select <code>for
122      All Users, on Port 80, as a Service - Recommended</code> if you'd
123      like your new Apache to listen at port 80 for incoming traffic.
124      It will run as a service (that is, Apache will run even if no one
125      is logged in on the server at the moment) Select <code>only for
126      the Current User, on Port 8080, when started Manually</code> if
127      you'd like to install Apache for your personal experimenting or
128      if you already have another WWW server running on port 80.</p></li>
129
130      <li><p><strong>The installation type.</strong> Select <code>Typical</code>
131      for everything except the source code and libraries for module
132      development. With <code>Custom</code> you can specify what to
133      install. A full install will require about 13 megabytes of free
134      disk space. This does <em>not</em> include the size of your web
135      site(s).</p></li>
136
137      <li><p><strong>Where to install.</strong> The default path is
138      <code>C:\Program Files\Apache Software Foundation</code>
139      under which a directory called 
140      <code>Apache2.2</code> will be created by default.</p></li>
141    </ol>
142
143    <p>During the installation, Apache will configure the files in the
144    <code>conf</code> subdirectory to reflect the chosen installation
145    directory. However, if any of the configuration files in this
146    directory already exist, they will not be overwritten. Instead, the
147    new copy of the corresponding file will be left with the extension
148    <code>.default</code>. So, for example, if <code>conf\httpd.conf</code>
149    already exists, it will be renamed as <code>conf\httpd.conf.default</code>.
150    After the installation you should manually check to see what new
151    settings are in the <code>.default</code> file, and if necessary,
152    update your existing configuration file.</p>
153
154    <p>Also, if you already have a file called <code>htdocs\index.html</code>,
155    it will not be overwritten (and no <code>index.html.default</code>
156    will be installed either). This means it should be safe to install
157    Apache over an existing installation, although you would have to
158    stop the existing running server before doing the installation, and
159    then start the new one after the installation is finished.</p>
160
161    <p>After installing Apache, you must edit the configuration files
162    in the <code>conf</code> subdirectory as required. These files
163    will be configured during the installation so that Apache is ready
164    to be run from the directory it was installed into, with the
165    documents server from the subdirectory <code>htdocs</code>. There
166    are lots of other options which you should set before you really
167    start using Apache. However, to get started quickly, the files
168    should work as installed.</p>
169  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
170<div class="section">
171<h2><a name="advinst" id="advinst">Advanced Installation Topics</a></h2>
172    
173
174    <p>One feature of the installer, "Build Headers and Libraries", can be
175    ignored by most users, but should be installed if compiling third party
176    modules.  The "APR Iconv Code Pages" can similarly be omitted by most
177    users, unless using <code class="module"><a href="/mod/mod_charset_lite.html">mod_charset_lite</a></code> or a third party
178    module which relies on APR internationalization features.</p>
179
180    <p>There are requests to ship a .zip file from time to time.  There is
181    no point in the ASF consuming additional storage, mirroring and bandwidth
182    for this purpose, because the .msi installer allows the installation
183    artifacts to all be unpacked using the <code>msiexec /a</code> network
184    installation option.  Using this command against any .msi will result
185    in an exploded tree of all of the individual files and components.</p>
186
187    <p>The installation options above can be customized by users familiar
188    with msiexec.exe options and silent installation.  The actual installer
189    sources are available in the httpd/httpd/win32-msi/ tree of the httpd
190    project subversion respository.  For reference, some of the more common
191    variables which may be modified are;</p>
192
193    <ul>
194      <li><code>AgreeToLicense</code> (toggle to "Yes")</li>
195      <li><code>ALLUSERS</code> (choose between Null and "1")</li>
196      <li><code>ApplicationUsers</code> (toggle to "OnlyCurrentUser")</li>
197      <li><code>EXISTING_APACHE_SERVICE_PATH</code></li>
198      <li><code>INSTALLDIR</code> (default "ProgramFilesFolder\Apache Software Foundation\Apache2.2\")</li>
199      <li><code>INSTALLLEVEL</code> (default "100", refer to list below)</li>
200      <li><code>RESOLVED_WINSOCK2</code> (toggle to "1")</li>
201      <li><code>SERVERADMIN</code></li>
202      <li><code>SERVERDOMAIN</code></li>
203      <li><code>SERVERNAME</code></li>
204      <li><code>SERVERPORT</code> (default "80")</li>
205      <li><code>SERVERSSLPORT</code> (default "443")</li>
206      <li><code>SERVICEINTERNALNAME</code> (default "Apache2.2", no spaces!)</li>
207      <li><code>SERVICENAME</code> (default "Apache2.2", include spaces)</li>
208      <li><code>SetupType</code> (default "Typical")</li>
209    </ul>
210
211    <p>The installation level of various features, which may be individually
212    toggled, include;</p>
213
214    <ul>
215      <li>Apache (1, base Apache HTTP Server 2.2 feature)</li>
216      <li>ApacheDocs (11, Apache Documentation)</li>
217      <li>ApacheMonitoring (41, Apache Service Taskbar Icon)</li>
218      <li>ApacheRuntime (1, Apache Runtime)</li>
219      <li>BuildFiles (101, Build Headers and Libraries)</li>
220      <li>Iconv (21, APR Iconv Code Pages)</li>
221      <li>OpensslBin (31, OpenSSL Runtime)</li>
222      <li>SslBin (41, Ssl Binaries)</li>
223    </ul>
224
225
226  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
227<div class="section">
228<h2><a name="cust" id="cust">Customizing Apache for Windows</a></h2>
229    
230
231    <p>Apache is configured by the files in the <code>conf</code>
232    subdirectory. These are the same files used to configure the Unix
233    version, but there are a few different directives for Apache on
234    Windows. See the <a href="/mod/directives.html">directive index</a>
235    for all the available directives.</p>
236
237    <p>The main differences in Apache for Windows are:</p>
238    <ul>
239      <li><p>Because Apache for Windows is multithreaded, it does not
240      use a separate process for each request, as Apache can on Unix.
241      Instead there are usually only two Apache processes running: a
242      parent process, and a child which handles the requests. Within
243      the child process each request is handled by a separate thread.
244      </p>
245
246      <p>The process management directives are also different:</p>
247
248      <p><code class="directive"><a href="/mod/mpm_common.html#maxrequestsperchild">MaxRequestsPerChild</a></code>:
249      Like the Unix directive, this controls how many requests (actually,
250      connections) which a single child process will serve before exiting.
251      However, unlike on Unix, a replacement process is not instantly
252      available.  Use the default <code>MaxRequestsPerChild 0</code>,
253      unless instructed to change the behavior to overcome a memory leak
254      in third party modules or in-process applications.</p>
255
256      <div class="warning"><strong>Warning: The server configuration
257      file is reread when a new child process is started. If you have
258      modified <code>httpd.conf</code>, the new child may not start or
259      you may receive unexpected results.</strong></div>
260
261      <p><code class="directive"><a href="/mod/mpm_common.html#threadsperchild">ThreadsPerChild</a></code>:
262      This directive is new. It tells the server how many threads it
263      should use. This is the maximum number of connections the server
264      can handle at once, so be sure to set this number high enough for
265      your site if you get a lot of hits. The recommended default is
266      <code>ThreadsPerChild 150</code>, but this must be adjusted to
267      reflect the greatest anticipated number of simultaneous
268      connections to accept.</p></li>
269
270      <li><p>The directives that accept filenames as arguments must use
271      Windows filenames instead of Unix ones. However, because Apache
272      may interpret backslashes as an "escape character" sequence, you
273      should consistently use forward slashes in path names, not 
274      backslashes.</p></li>
275
276      <li><p>While filenames are generally case-insensitive on
277      Windows, URLs are still treated internally as case-sensitive
278      before they are mapped to the filesystem.  For example, the
279      <code class="directive"><a href="/mod/core.html#location">&lt;Location&gt;</a></code>,
280      <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>, and <code class="directive"><a href="/mod/mod_proxy.html#proxypass">ProxyPass</a></code> directives all use
281      case-sensitive arguments.  For this reason, it is particularly
282      important to use the <code class="directive"><a href="/mod/core.html#directory">&lt;Directory&gt;</a></code> directive when attempting
283      to limit access to content in the filesystem, since this
284      directive applies to any content in a directory, regardless of
285      how it is accessed.  If you wish to assure that only lowercase
286      is used in URLs, you can use something like:</p>
287
288      <div class="example"><p><code>
289      RewriteEngine On<br />
290      RewriteMap lowercase int:tolower<br />
291      RewriteCond %{REQUEST_URI} [A-Z]<br />
292      RewriteRule (.*) ${lowercase:$1} [R,L]
293      </code></p></div></li>
294
295      <li><p>When running, Apache needs write access only to the logs
296      directory and any configured cache directory tree.  Due to the
297      issue of case insensitive and short 8.3 format names, Apache must
298      validate all path names given.  This means that each directory
299      which Apache evaluates, from the drive root up to the directory
300      leaf, must have read, list and traverse directory permissions.
301      If Apache2.2 is installed at C:\Program Files, then the root
302      directory, Program Files and Apache2.2 must all be visible
303      to Apache.</p></li>
304
305      <li><p>Apache for Windows contains the ability to load modules at
306      runtime, without recompiling the server. If Apache is compiled
307      normally, it will install a number of optional modules in the
308      <code>\Apache2.2\modules</code> directory. To activate these or
309      other modules, the new <code class="directive"><a href="/mod/mod_so.html#loadmodule">LoadModule</a></code>
310      directive must be used. For example, to activate the status
311      module, use the following (in addition to the status-activating
312      directives in <code>access.conf</code>):</p>
313
314      <div class="example"><p><code>
315        LoadModule status_module modules/mod_status.so
316      </code></p></div>
317
318      <p>Information on <a href="/mod/mod_so.html#creating">creating
319      loadable modules</a> is also available.</p></li>
320
321      <li><p>Apache can also load ISAPI (Internet Server Application
322      Programming Interface) extensions such as those used by Microsoft
323      IIS and other Windows servers. <a href="/mod/mod_isapi.html">More
324      information is available</a>. Note that Apache <strong>cannot</strong>
325      load ISAPI Filters, and ISAPI Handlers with some Microsoft feature
326      extensions will not work.</p></li>
327
328      <li><p>When running CGI scripts, the method Apache uses to find
329      the interpreter for the script is configurable using the
330      <code class="directive"><a href="/mod/core.html#scriptinterpretersource">ScriptInterpreterSource</a></code>
331      directive.</p></li>
332
333      <li><p>Since it is often difficult to manage files with names
334      like <code>.htaccess</code> in Windows, you may find it useful to
335      change the name of this per-directory configuration file using
336      the <code class="directive"><a href="/mod/core.html#accessfilename">AccessFilename</a></code>
337      directive.</p></li>
338
339      <li><p>Any errors during Apache startup are logged into the
340      Windows event log when running on Windows NT. This mechanism
341      acts as a backup for those situations where Apache is not yet
342      prepared to use the <code>error.log</code> file. You can
343      review the Windows Application Event Log by using the Event Viewer,
344      e.g. Start - Settings - Control Panel - Administrative Tools
345      - Event Viewer.</p></li>
346    </ul>
347
348  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
349<div class="section">
350<h2><a name="winsvc" id="winsvc">Running Apache as a Service</a></h2>
351    
352
353    <p>You can install Apache as a service automatically during the
354    installation. If you chose to install for all users, the
355    installation will create an Apache service for you. If you specify
356    to install for yourself only, you can manually register Apache as a
357    service after the installation. You have to be a member of the
358    Administrators group for the service installation to succeed.</p>
359
360    <p>Apache comes with a utility called the Apache Service Monitor.
361    With it you can see and manage the state of all installed Apache
362    services on any machine on your network. To be able to manage an
363    Apache service with the monitor, you have to first install the
364    service (either automatically via the installation or manually).
365    </p>
366
367    <p>You can install Apache as a Windows NT service as follows from
368    the command prompt at the Apache <code>bin</code> subdirectory:</p>
369
370    <div class="example"><p><code>
371      httpd.exe -k install
372    </code></p></div>
373
374    <p>If you need to specify the name of the service you want to
375    install, use the following command. You have to do this if you
376    have several different service installations of Apache on your
377    computer. If you specify a name during the install, you have to
378    also specify it during any other -k operation.</p>
379
380    <div class="example"><p><code>
381      httpd.exe -k install -n "MyServiceName"
382    </code></p></div>
383
384    <p>If you need to have specifically named configuration files for
385    different services, you must use this:</p>
386
387    <div class="example"><p><code>
388      httpd.exe -k install -n "MyServiceName" -f "c:\files\my.conf"
389    </code></p></div>
390
391    <p>If you use the first command without any special parameters except
392    <code>-k install</code>, the service will be called <code>Apache2.2</code>
393    and the configuration will be assumed to be <code>conf\httpd.conf</code>.
394    </p>
395
396    <p>Removing an Apache service is easy. Just use:</p>
397
398    <div class="example"><p><code>
399      httpd.exe -k uninstall
400    </code></p></div>
401
402    <p>The specific Apache service to be uninstalled can be specified by using:</p>
403
404    <div class="example"><p><code>
405      httpd.exe -k uninstall -n "MyServiceName"
406    </code></p></div>
407
408    <p>Normal starting, restarting and shutting down of an Apache
409    service is usually done via the Apache Service Monitor, by using
410    commands like <code>NET START Apache2.2</code> and <code>NET STOP
411    Apache2.2</code> or via normal Windows service management. Before
412    starting Apache as a service by any means, you should test the
413    service's configuration file by using:</p>
414
415    <div class="example"><p><code>
416      httpd.exe -n "MyServiceName" -t
417    </code></p></div>
418
419    <p>You can control an Apache service by its command line switches,
420    too. To start an installed Apache service you'll use this:</p>
421
422    <div class="example"><p><code>
423      httpd.exe -k start -n "MyServiceName"
424    </code></p></div>
425
426    <p>To stop an Apache service via the command line switches, use
427    this:</p>
428
429    <div class="example"><p><code>
430      httpd.exe -k stop -n "MyServiceName"
431    </code></p></div>
432
433    <p>or</p>
434
435    <div class="example"><p><code>
436      httpd.exe -k shutdown -n "MyServiceName"
437    </code></p></div>
438
439    <p>You can also restart a running service and force it to reread
440    its configuration file by using:</p>
441
442    <div class="example"><p><code>
443      httpd.exe -k restart -n "MyServiceName"
444    </code></p></div>
445
446    <p>By default, all Apache services are registered to run as the
447    system user (the <code>LocalSystem</code> account). The
448    <code>LocalSystem</code> account has no privileges to your network
449    via any Windows-secured mechanism, including the file system, named
450    pipes, DCOM, or secure RPC. It has, however, wide privileges locally.
451    </p>
452
453    <div class="warning"><strong>Never grant any network privileges to
454    the <code>LocalSystem</code> account! If you need Apache to be able
455    to access network resources, create a separate account for Apache as
456    noted below.</strong></div>
457
458    <p>It is recommended that users create a separate account for running
459    Apache service(s). If you have to access network resources via Apache,
460    this is required.</p>
461
462    <ol>
463      <li>Create a normal domain user account, and be sure to
464      memorize its password.</li>
465
466      <li>Grant the newly-created user a privilege of <code>Log on
467      as a service</code> and <code>Act as part of the operating
468      system</code>. On Windows NT 4.0 these privileges are granted via
469      User Manager for Domains, but on Windows 2000 and XP you probably
470      want to use Group Policy for propagating these settings. You can
471      also manually set these via the Local Security Policy MMC snap-in.
472      </li>
473
474      <li>Confirm that the created account is a member of the Users
475      group.</li>
476
477      <li>Grant the account read and execute (RX) rights to all document
478      and script folders (<code>htdocs</code> and <code>cgi-bin</code>
479      for example).</li>
480
481      <li>Grant the account change (RWXD) rights to the
482      Apache <code>logs</code> directory.</li>
483
484      <li>Grant the account read and execute (RX) rights to the
485      <code>httpd.exe</code> binary executable.</li>
486    </ol>
487
488    <div class="note">It is usually a good practice to grant the user the Apache
489    service runs as read and execute (RX) access to the whole Apache2.2
490    directory, except the <code>logs</code> subdirectory, where the
491    user has to have at least change (RWXD) rights.</div>
492
493    <p>If you allow the account to log in as a user and as a service,
494    then you can log on with that account and test that the account has
495    the privileges to execute the scripts, read the web pages, and that
496    you can start Apache in a console window. If this works, and you
497    have followed the steps above, Apache should execute as a service
498    with no problems.</p>
499
500    <div class="note"><strong>Error code 2186</strong> is a good indication that
501    you need to review the "Log On As" configuration for the service,
502    since Apache cannot access a required network resource. Also, pay
503    close attention to the privileges of the user Apache is
504    configured to run as.</div>
505
506    <p>When starting Apache as a service you may encounter an error
507    message from the Windows Service Control Manager. For example,
508    if you try to start Apache by using the Services applet in the
509    Windows Control Panel, you may get the following message:</p>
510
511    <div class="example"><p><code>
512      Could not start the Apache2.2 service on \\COMPUTER <br />
513      Error 1067; The process terminated unexpectedly.
514    </code></p></div>
515
516    <p>You will get this generic error if there is any problem with
517    starting the Apache service. In order to see what is really causing
518    the problem you should follow the instructions for Running Apache
519    for Windows from the Command Prompt.</p>
520
521    <p>If you are having problems with the service, it is suggested
522    you follow the instructions below to try starting httpd.exe from
523    a console window, and work out the errors before struggling to
524    start it as a service again.</p>
525  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
526<div class="section">
527<h2><a name="wincons" id="wincons">Running Apache as a Console Application</a></h2>
528    
529
530    <p>Running Apache as a service is usually the recommended way to
531    use it, but it is sometimes easier to work from the command line
532    (on Windows 9x running Apache from the command line is the
533    recommended way due to the lack of reliable service support.)</p>
534
535    <p>To run Apache from the command line as a console application,
536    use the following command:</p>
537
538    <div class="example"><p><code>
539      httpd.exe
540    </code></p></div>
541
542    <p>Apache will execute, and will remain running until it is stopped
543    by pressing Control-C.</p>
544
545    <p>You can also run Apache via the shortcut Start Apache in Console
546    placed to <code>Start Menu --&gt; Programs --&gt; Apache HTTP Server
547    2.2.xx --&gt; Control Apache Server</code> during the installation.
548    This will open a console window and start Apache inside it. If you
549    don't have Apache installed as a service, the window will remain
550    visible until you stop Apache by pressing Control-C in the console
551    window where Apache is running in. The server will exit in a few
552    seconds. However, if you do have Apache installed as a service, the
553    shortcut starts the service. If the Apache service is running
554    already, the shortcut doesn't do anything.</p>
555
556    <p>If Apache is running as a service, you can tell it to stop by opening another console
557    window and entering:</p>
558
559    <div class="example"><p><code>
560      httpd.exe -k shutdown
561    </code></p></div>
562
563    <p>Running as a service should be preferred over running in a
564    console window because this lets Apache end any current operations
565    and clean up gracefully.</p>
566
567    <p>But if the server is running in a console window, you can
568    only stop it by pressing Control-C in the same window.</p>
569
570    <p>You can also tell Apache to restart. This forces it to reread
571    the configuration file. Any operations in progress are allowed to
572    complete without interruption. To restart Apache, either press
573    Control-Break in the console window you used for starting Apache,
574    or enter</p>
575
576    <div class="example"><p><code>
577      httpd.exe -k restart
578    </code></p></div>
579
580    <p>if the server is running as a service.</p>
581
582    <div class="note">Note for people familiar with the Unix version of Apache:
583    these commands provide a Windows equivalent to <code>kill -TERM
584    <em>pid</em></code> and <code>kill -USR1 <em>pid</em></code>. The
585    command line option used, <code>-k</code>, was chosen as a reminder
586    of the <code>kill</code> command used on Unix.</div>
587
588    <p>If the Apache console window closes immediately or unexpectedly
589    after startup, open the Command Prompt from the Start Menu --&gt;
590    Programs. Change to the folder to which you installed Apache, type
591    the command <code>httpd.exe</code>, and read the error message. Then
592    change to the logs folder, and review the <code>error.log</code>
593    file for configuration mistakes. If you accepted the defaults when
594    you installed Apache, the commands would be:</p>
595
596    <div class="example"><p><code>
597      c: <br />
598      cd "\Program Files\Apache Software Foundation\Apache2.2\bin" <br />
599      httpd.exe
600    </code></p></div>
601
602    <p>Then wait for Apache to stop, or press Control-C. Then enter the
603    following:</p>
604
605    <div class="example"><p><code>
606      cd ..\logs <br />
607      more &lt; error.log
608    </code></p></div>
609
610    <p>When working with Apache it is important to know how it will
611    find the configuration file. You can specify a configuration file
612    on the command line in two ways:</p>
613
614    <ul>
615      <li><p><code>-f</code> specifies an absolute or relative path to
616      a particular configuration file:</p>
617
618      <div class="example"><p><code>
619        httpd.exe -f "c:\my server files\anotherconfig.conf"
620      </code></p></div>
621
622      <p>or</p>
623
624      <div class="example"><p><code>
625        httpd.exe -f files\anotherconfig.conf
626      </code></p></div></li>
627
628      <li><p><code>-n</code> specifies the installed Apache service
629      whose configuration file is to be used:</p>
630
631      <div class="example"><p><code>
632        httpd.exe -n "MyServiceName"
633      </code></p></div>
634      </li>
635    </ul>
636
637    <p>In both of these cases, the proper
638    <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code> should be set in
639    the configuration file.</p>
640
641    <p>If you don't specify a configuration file with <code>-f</code>
642    or <code>-n</code>, Apache will use the file name compiled into the
643    server, such as <code>conf\httpd.conf</code>. This built-in path
644    is relative to the installation directory. You can verify the compiled
645    file name from a value labelled as <code>SERVER_CONFIG_FILE</code> when
646    invoking Apache with the <code>-V</code> switch, like this:</p>
647
648    <div class="example"><p><code>
649      httpd.exe -V
650    </code></p></div>
651
652    <p>Apache will then try to determine its <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code> by trying the following, in this order:</p>
653
654    <ol>
655      <li>A <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code> directive
656      via the <code>-C</code> command line switch.</li>
657
658      <li>The <code>-d</code> switch on the command line.</li>
659
660      <li>Current working directory.</li>
661
662      <li>A registry entry which was created if you did a binary
663      installation.</li>
664
665      <li>The server root compiled into the server. This is <code>
666      /apache</code> by default, you can verify it by using <code>
667      httpd.exe -V</code> and looking for a value labelled as
668      <code>HTTPD_ROOT</code>.</li>
669    </ol>
670
671    <p>During the installation, a version-specific registry key is
672    created in the Windows registry. The location of this key depends
673    on the type of the installation. If you chose to install Apache
674    for all users, the key is located under the
675    <code>HKEY_LOCAL_MACHINE</code> hive, like this (the version
676    numbers will of course vary between different versions of Apache:
677    </p>
678
679    <div class="example"><p><code>
680      HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Apache\2.2.2
681    </code></p></div>
682
683    <p>Correspondingly, if you chose to install Apache for the current
684    user only, the key is located under the <code>HKEY_CURRENT_USER</code>
685    hive, the contents of which are dependent of the user currently
686    logged on:</p>
687
688    <div class="example"><p><code>
689      HKEY_CURRENT_USER\SOFTWARE\Apache Software Foundation\Apache\2.2.2
690    </code></p></div>
691
692    <p>This key is compiled into the server and can enable you to test
693    new versions without affecting the current version. Of course, you
694    must take care not to install the new version in the same
695    directory as another version.</p>
696
697    <p>If you did not do a binary install, Apache will in some
698    scenarios complain about the missing registry key. This warning can
699    be ignored if the server was otherwise able to find its
700    configuration file.</p>
701
702    <p>The value of this key is the
703    <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code> directory which
704    contains the <code>conf</code> subdirectory. When Apache starts it
705    reads the <code>httpd.conf</code> file from that directory. If
706    this file contains a <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code>
707    directive which contains a different directory from the one
708    obtained from the registry key above, Apache will forget the
709    registry key and use the directory from the configuration file. If
710    you copy the Apache directory or configuration files to a new
711    location it is vital that you update the
712    <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code> directive in the
713    <code>httpd.conf</code> file to reflect the new location.</p>
714  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
715<div class="section">
716<h2><a name="test" id="test">Testing the Installation</a></h2>
717    
718
719    <p>After starting Apache (either in a console window or as a
720    service) it will be listening on port 80 (unless you changed the
721    <code class="directive"><a href="/mod/mpm_common.html#listen">Listen</a></code> directive in the
722    configuration files or installed Apache only for the current user).
723    To connect to the server and access the default page, launch a
724    browser and enter this URL:</p>
725
726    <div class="example"><p><code>
727      http://localhost/
728    </code></p></div>
729
730    <p>Apache should respond with a welcome page and you should see
731    "It Works!". If nothing happens or you get an error, look in the
732    <code>error.log</code> file in the <code>logs</code> subdirectory.
733    If your host is not connected to the net, or if you have serious
734    problems with your DNS (Domain Name Service) configuration, you
735    may have to use this URL:</p>
736
737    <div class="example"><p><code>
738      http://127.0.0.1/
739    </code></p></div>
740
741    <p>If you happen to be running Apache on an alternate port, you
742    need to explicitly put that in the URL:</p>
743
744    <div class="example"><p><code>
745      http://127.0.0.1:8080/
746    </code></p></div>
747
748    <p>Once your basic installation is working, you should configure it
749    properly by editing the files in the <code>conf</code> subdirectory.
750    Again, if you change the configuration of the Windows NT service
751    for Apache, first attempt to start it from the command line to
752    make sure that the service starts with no errors.</p>
753
754    <p>Because Apache <strong>cannot</strong> share the same port with
755    another TCP/IP application, you may need to stop, uninstall or reconfigure
756    certain other services before running Apache. These conflicting
757    services include other WWW servers, some firewall implementations,
758    and even some client applications (such as Skype) which will use port
759    80 to attempt to bypass firewall issues.</p>
760  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
761<div class="section">
762<h2><a name="windrivemap" id="windrivemap">Configuring Access to Network Resources</a></h2>
763    
764
765  <p>Access to files over the network can be specified using two
766  mechanisms provided by Windows:</p>
767
768  <dl>
769    <dt>Mapped drive letters</dt>
770    <dd>e.g., <code>Alias /images/ Z:/</code></dd>
771
772    <dt>UNC paths</dt>
773    <dd>e.g., <code>Alias /images/ //imagehost/www/images/</code></dd>
774  </dl>
775
776  <p>Mapped drive letters allow the administrator to maintain the
777  mapping to a specific machine and path outside of the Apache httpd
778  configuration.  However, these mappings are associated only with
779  interactive sessions and are not directly available to Apache httpd
780  when it is started as a service.  <strong>Use only UNC paths for
781  network resources in httpd.conf</strong> so that the resources can
782  be accessed consistently regardless of how Apache httpd is started.
783  (Arcane and error prone procedures may work around the restriction
784  on mapped drive letters, but this is not recommended.)</p>
785
786  <div class="example"><h3>Example DocumentRoot with UNC path</h3><p><code>
787  DocumentRoot //dochost/www/html/
788  </code></p></div>
789
790  <div class="example"><h3>Example DocumentRoot with IP address in UNC path</h3><p><code>
791  DocumentRoot //192.168.1.50/docs/<br />
792  </code></p></div>
793
794  <div class="example"><h3>Example Alias and corresponding Directory with UNC path</h3><p><code>
795  Alias /images/ //imagehost/www/images/<br />
796  <br />
797  &lt;Directory //imagehost/www/images/&gt;<br />
798  ...<br />
799  &lt;Directory&gt;<br />
800  </code></p></div>
801
802  <p>When running Apache httpd as a service, you must create a
803  separate account in order to access network resources, as described
804  above.</p>
805  </div></div>
806<div class="bottomlang">
807<p><span>Available Languages: </span><a href="/en/platform/windows.html" title="English">&nbsp;en&nbsp;</a> |
808<a href="/ko/platform/windows.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
809</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
810<script type="text/javascript"><!--//--><![CDATA[//><!--
811var comments_shortname = 'httpd';
812var comments_identifier = 'http://httpd.apache.org/docs/2.2/platform/windows.html';
813(function(w, d) {
814    if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
815        d.write('<div id="comments_thread"><\/div>');
816        var s = d.createElement('script');
817        s.type = 'text/javascript';
818        s.async = true;
819        s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
820        (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
821    }
822    else { 
823        d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
824    }
825})(window, document);
826//--><!]]></script></div><div id="footer">
827<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
828<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
829if (typeof(prettyPrint) !== 'undefined') {
830    prettyPrint();
831}
832//--><!]]></script>
833</body></html>