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