windows.xml revision 05c989e9f795b0a0097d9d29aa3e5167292d0a45
967e5f3c25249c779575864692935627004d3f9eChristian Maeder<?xml version="1.0" encoding="UTF-8" ?>
967e5f3c25249c779575864692935627004d3f9eChristian Maeder<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
967e5f3c25249c779575864692935627004d3f9eChristian Maeder<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
75a6279dbae159d018ef812185416cf6df386c10Till Mossakowski<!-- $LastChangedRevision$ -->
967e5f3c25249c779575864692935627004d3f9eChristian Maeder
e7ce154edb906685b3fa7f6c0a764e18a4658068Christian Maeder<!--
967e5f3c25249c779575864692935627004d3f9eChristian Maeder Licensed to the Apache Software Foundation (ASF) under one or more
89054b2b95a3f92e78324dc852f3d34704e2ca49Christian Maeder contributor license agreements. See the NOTICE file distributed with
967e5f3c25249c779575864692935627004d3f9eChristian Maeder this work for additional information regarding copyright ownership.
967e5f3c25249c779575864692935627004d3f9eChristian Maeder The ASF licenses this file to You under the Apache License, Version 2.0
967e5f3c25249c779575864692935627004d3f9eChristian Maeder (the "License"); you may not use this file except in compliance with
967e5f3c25249c779575864692935627004d3f9eChristian Maeder the License. You may obtain a copy of the License at
967e5f3c25249c779575864692935627004d3f9eChristian Maeder
967e5f3c25249c779575864692935627004d3f9eChristian Maeder http://www.apache.org/licenses/LICENSE-2.0
967e5f3c25249c779575864692935627004d3f9eChristian Maeder
fd896e2068ad7e50aed66ac18c3720ea7ff2619fChristian Maeder Unless required by applicable law or agreed to in writing, software
7221c71b38c871ce66eee4537cb681d468308dfbChristian Maeder distributed under the License is distributed on an "AS IS" BASIS,
0a8ea95bcf0e3f84fed0b725c049ec2a956a4a28Christian Maeder WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ac19f8695aa1b2d2d1cd1319da2530edd8f46a96Christian Maeder See the License for the specific language governing permissions and
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder limitations under the License.
8b9fda012e5ee53b7b2320c0638896a0ff6e99f3Christian Maeder-->
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder
fd896e2068ad7e50aed66ac18c3720ea7ff2619fChristian Maeder<manualpage metafile="windows.xml.meta">
997c56f3bc74a703043010978e5013fdb074d659Christian Maeder <parentdocument href="./">Platform Specific Notes</parentdocument>
967e5f3c25249c779575864692935627004d3f9eChristian Maeder
9744c7d9fa61d255d5e73beec7edc3499522e9e2Till Mossakowski <title>Using Apache HTTP Server on Microsoft Windows</title>
9744c7d9fa61d255d5e73beec7edc3499522e9e2Till Mossakowski
fd896e2068ad7e50aed66ac18c3720ea7ff2619fChristian Maeder <summary>
fd896e2068ad7e50aed66ac18c3720ea7ff2619fChristian Maeder <p>This document explains how to install, configure and run
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder Apache 2.&httpd.minor; under Microsoft Windows. If you have questions after
fd896e2068ad7e50aed66ac18c3720ea7ff2619fChristian Maeder reviewing the documentation (and any event and error logs), you
dea4c92f0c061d589c542d0640a18dab36dfbb46Christian Maeder should consult the peer-supported
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <a href="http://httpd.apache.org/userslist.html">users' mailing
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder list</a>.</p>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
dea4c92f0c061d589c542d0640a18dab36dfbb46Christian Maeder <p>This document assumes that you are installing a binary
dea4c92f0c061d589c542d0640a18dab36dfbb46Christian Maeder distribution of Apache. If you want to compile Apache yourself
967e5f3c25249c779575864692935627004d3f9eChristian Maeder (possibly to help with development or tracking down bugs),
dea4c92f0c061d589c542d0640a18dab36dfbb46Christian Maeder see <a href="win_compiling.html">Compiling Apache for Microsoft
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder Windows</a>.</p>
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder </summary>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <section id="req">
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <title>Operating System Requirements</title>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <p>The primary Windows platform for running Apache 2.&httpd.minor; is Windows
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder 2000 or later. Always obtain and
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder install the current service pack to avoid operating system bugs.</p>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder <note>Apache HTTP Server versions later than 2.2 will not run on any
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder operating system earlier than Windows 2000.</note>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder </section>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <section id="down">
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder <title>Downloading Apache for Windows</title>
0a8ea95bcf0e3f84fed0b725c049ec2a956a4a28Christian Maeder
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder <p>The Apache HTTP Server Project itself does not provide binary releases of
7a879b08ae0ca30006f9be887a73212b07f10204Christian Maeder software, only source code. If you cannot compile the Apache HTTP Server
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder yourself, you can obtain a binary package from numerous binary distributions
0f67ca7b0c738a28f6688ba6e96d44d7c14af611Christian Maeder available on the Internet.</p>
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder
7a879b08ae0ca30006f9be887a73212b07f10204Christian Maeder <p>Popular options for deploying Apache httpd, and, optionally, PHP
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder and MySQL, on Microsoft Windows, include:</p>
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder <ul>
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder <li><a href="http://www.apachelounge.com/download/">Apache
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder Lounge</a></li>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <li><a href="http://www.apachefriends.org/en/xampp.html">XAMPP, from
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder ApacheFriends</a></li>
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder <li><a href="http://www.wampserver.com/">WampServer</a></li>
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder </ul>
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder </section>
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <section id="cust">
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <title>Customizing Apache for Windows</title>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <p>Apache is configured by the files in the <code>conf</code>
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder subdirectory. These are the same files used to configure the Unix
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder version, but there are a few different directives for Apache on
e7ce154edb906685b3fa7f6c0a764e18a4658068Christian Maeder Windows. See the <a href="/mod/directives.html">directive index</a>
e7ce154edb906685b3fa7f6c0a764e18a4658068Christian Maeder for all the available directives.</p>
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder <p>The main differences in Apache for Windows are:</p>
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder <ul>
e7ce154edb906685b3fa7f6c0a764e18a4658068Christian Maeder <li><p>Because Apache for Windows is multithreaded, it does not
e7ce154edb906685b3fa7f6c0a764e18a4658068Christian Maeder use a separate process for each request, as Apache can on Unix.
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder Instead there are usually only two Apache processes running: a
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder parent process, and a child which handles the requests. Within
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder the child process each request is handled by a separate thread.
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder </p>
e7ce154edb906685b3fa7f6c0a764e18a4658068Christian Maeder
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder <p>The process management directives are also different:</p>
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder <p><directive module="mpm_common">MaxConnectionsPerChild</directive>:
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder Like the Unix directive, this controls how many connections a single
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder child process will serve before exiting.
0a8ea95bcf0e3f84fed0b725c049ec2a956a4a28Christian Maeder However, unlike on Unix, a replacement process is not instantly
967e5f3c25249c779575864692935627004d3f9eChristian Maeder available. Use the default <code>MaxConnectionsPerChild 0</code>,
0a8ea95bcf0e3f84fed0b725c049ec2a956a4a28Christian Maeder unless instructed to change the behavior to overcome a memory leak
967e5f3c25249c779575864692935627004d3f9eChristian Maeder in third party modules or in-process applications.</p>
83814002b4922114cbe7e9ba728472a0bf44aac5Christian Maeder
a578ec30cded5e396a7ce9a3b469e8cd3a88246aChristian Maeder <note type="warning"><strong>Warning: The server configuration
83814002b4922114cbe7e9ba728472a0bf44aac5Christian Maeder file is reread when a new child process is started. If you have
967e5f3c25249c779575864692935627004d3f9eChristian Maeder modified <code>httpd.conf</code>, the new child may not start or
83814002b4922114cbe7e9ba728472a0bf44aac5Christian Maeder you may receive unexpected results.</strong></note>
dedabc954aa15f6ad0764472a9434dc6dafe3db2Christian Maeder
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder <p><directive module="mpm_common">ThreadsPerChild</directive>:
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder This directive is new. It tells the server how many threads it
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder should use. This is the maximum number of connections the server
20e16bdd7481741d0b6b14f952aea42ee7a65efbChristian Maeder can handle at once, so be sure to set this number high enough for
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder your site if you get a lot of hits. The recommended default is
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian Maeder <code>ThreadsPerChild 150</code>, but this must be adjusted to
dedabc954aa15f6ad0764472a9434dc6dafe3db2Christian Maeder reflect the greatest anticipated number of simultaneous
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder connections to accept.</p></li>
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder
a578ec30cded5e396a7ce9a3b469e8cd3a88246aChristian Maeder <li><p>The directives that accept filenames as arguments must use
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian Maeder Windows filenames instead of Unix ones. However, because Apache
dedabc954aa15f6ad0764472a9434dc6dafe3db2Christian Maeder may interpret backslashes as an "escape character" sequence, you
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder should consistently use forward slashes in path names, not
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder backslashes.</p></li>
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <li><p>While filenames are generally case-insensitive on
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder Windows, URLs are still treated internally as case-sensitive
dedabc954aa15f6ad0764472a9434dc6dafe3db2Christian Maeder before they are mapped to the filesystem. For example, the
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian Maeder <directive module="core" type="section">Location</directive>,
dedabc954aa15f6ad0764472a9434dc6dafe3db2Christian Maeder <directive module="mod_alias">Alias</directive>, and <directive
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski module="mod_proxy">ProxyPass</directive> directives all use
7221c71b38c871ce66eee4537cb681d468308dfbChristian Maeder case-sensitive arguments. For this reason, it is particularly
7221c71b38c871ce66eee4537cb681d468308dfbChristian Maeder important to use the <directive module="core"
7221c71b38c871ce66eee4537cb681d468308dfbChristian Maeder type="section">Directory</directive> directive when attempting
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder to limit access to content in the filesystem, since this
842eedc62639561781b6c33533d1949693ef6cc5Christian Maeder directive applies to any content in a directory, regardless of
842eedc62639561781b6c33533d1949693ef6cc5Christian Maeder how it is accessed. If you wish to assure that only lowercase
842eedc62639561781b6c33533d1949693ef6cc5Christian Maeder is used in URLs, you can use something like:</p>
842eedc62639561781b6c33533d1949693ef6cc5Christian Maeder
842eedc62639561781b6c33533d1949693ef6cc5Christian Maeder <highlight language="config">
842eedc62639561781b6c33533d1949693ef6cc5Christian MaederRewriteEngine On
842eedc62639561781b6c33533d1949693ef6cc5Christian MaederRewriteMap lowercase int:tolower
842eedc62639561781b6c33533d1949693ef6cc5Christian MaederRewriteCond %{REQUEST_URI} [A-Z]
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till MossakowskiRewriteRule (.*) ${lowercase:$1} [R,L]
967e5f3c25249c779575864692935627004d3f9eChristian Maeder </highlight></li>
967e5f3c25249c779575864692935627004d3f9eChristian Maeder
967e5f3c25249c779575864692935627004d3f9eChristian Maeder <li><p>When running, Apache needs write access only to the logs
dedabc954aa15f6ad0764472a9434dc6dafe3db2Christian Maeder directory and any configured cache directory tree. Due to the
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder issue of case insensitive and short 8.3 format names, Apache must
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder validate all path names given. This means that each directory
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder which Apache evaluates, from the drive root up to the directory
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder leaf, must have read, list and traverse directory permissions.
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder If Apache2.&httpd.minor; is installed at C:\Program Files, then the root
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder directory, Program Files and Apache2.&httpd.minor; must all be visible
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder to Apache.</p></li>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <li><p>Apache for Windows contains the ability to load modules at
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder runtime, without recompiling the server. If Apache is compiled
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder normally, it will install a number of optional modules in the
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <code>\Apache2.&httpd.minor;\modules</code> directory. To activate these or
967e5f3c25249c779575864692935627004d3f9eChristian Maeder other modules, the new <directive module="mod_so">LoadModule</directive>
967e5f3c25249c779575864692935627004d3f9eChristian Maeder directive must be used. For example, to activate the status
7221c71b38c871ce66eee4537cb681d468308dfbChristian Maeder module, use the following (in addition to the status-activating
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder directives in <code>access.conf</code>):</p>
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder
83814002b4922114cbe7e9ba728472a0bf44aac5Christian Maeder <highlight language="config">
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder LoadModule status_module modules/mod_status.so
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder </highlight>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <p>Information on <a href="/mod/mod_so.html#creating">creating
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder loadable modules</a> is also available.</p></li>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <li><p>Apache can also load ISAPI (Internet Server Application
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder Programming Interface) extensions such as those used by Microsoft
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder IIS and other Windows servers. <a href="/mod/mod_isapi.html">More
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder information is available</a>. Note that Apache <strong>cannot</strong>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder load ISAPI Filters, and ISAPI Handlers with some Microsoft feature
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder extensions will not work.</p></li>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder <li><p>When running CGI scripts, the method Apache uses to find
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder the interpreter for the script is configurable using the
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <directive module="core">ScriptInterpreterSource</directive>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder directive.</p></li>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <li><p>Since it is often difficult to manage files with names
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder like <code>.htaccess</code> in Windows, you may find it useful to
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder change the name of this per-directory configuration file using
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder the <directive module="core">AccessFilename</directive>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder directive.</p></li>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <li><p>Any errors during Apache startup are logged into the
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder Windows event log when running on Windows NT. This mechanism
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder acts as a backup for those situations where Apache is not yet
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder prepared to use the <code>error.log</code> file. You can
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder review the Windows Application Event Log by using the Event Viewer,
7221c71b38c871ce66eee4537cb681d468308dfbChristian Maeder e.g. Start - Settings - Control Panel - Administrative Tools
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder - Event Viewer.</p></li>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder </ul>
967e5f3c25249c779575864692935627004d3f9eChristian Maeder
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder </section>
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder
83814002b4922114cbe7e9ba728472a0bf44aac5Christian Maeder <section id="winsvc">
83814002b4922114cbe7e9ba728472a0bf44aac5Christian Maeder <title>Running Apache as a Service</title>
dedabc954aa15f6ad0764472a9434dc6dafe3db2Christian Maeder
dedabc954aa15f6ad0764472a9434dc6dafe3db2Christian Maeder <p>Apache comes with a utility called the Apache Service Monitor.
97ee7048e63953c5617342ce38c30cbcb35cc0beChristian Maeder With it you can see and manage the state of all installed Apache
97ee7048e63953c5617342ce38c30cbcb35cc0beChristian Maeder services on any machine on your network. To be able to manage an
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder Apache service with the monitor, you have to first install the
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder service (either automatically via the installation or manually).
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder </p>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <p>You can install Apache as a Windows NT service as follows from
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder the command prompt at the Apache <code>bin</code> subdirectory:</p>
dedabc954aa15f6ad0764472a9434dc6dafe3db2Christian Maeder
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder <example>
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder httpd.exe -k install
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder </example>
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder <p>If you need to specify the name of the service you want to
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder install, use the following command. You have to do this if you
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder have several different service installations of Apache on your
07b72edb610ee53b4832d132e96b0a3d8423f8ebChristian Maeder computer. If you specify a name during the install, you have to
also specify it during any other -k operation.</p>
<example>
httpd.exe -k install -n "MyServiceName"
</example>
<p>If you need to have specifically named configuration files for
different services, you must use this:</p>
<example>
httpd.exe -k install -n "MyServiceName" -f "c:\files\my.conf"
</example>
<p>If you use the first command without any special parameters except
<code>-k install</code>, the service will be called <code>Apache2.&httpd.minor;</code>
and the configuration will be assumed to be <code>conf\httpd.conf</code>.
</p>
<p>Removing an Apache service is easy. Just use:</p>
<example>
httpd.exe -k uninstall
</example>
<p>The specific Apache service to be uninstalled can be specified by using:</p>
<example>
httpd.exe -k uninstall -n "MyServiceName"
</example>
<p>Normal starting, restarting and shutting down of an Apache
service is usually done via the Apache Service Monitor, by using
commands like <code>NET START Apache2.&httpd.minor;</code> and <code>NET STOP
Apache2.&httpd.minor;</code> or via normal Windows service management. Before
starting Apache as a service by any means, you should test the
service's configuration file by using:</p>
<example>
httpd.exe -n "MyServiceName" -t
</example>
<p>You can control an Apache service by its command line switches,
too. To start an installed Apache service you'll use this:</p>
<example>
httpd.exe -k start -n "MyServiceName"
</example>
<p>To stop an Apache service via the command line switches, use
this:</p>
<example>
httpd.exe -k stop -n "MyServiceName"
</example>
<p>or</p>
<example>
httpd.exe -k shutdown -n "MyServiceName"
</example>
<p>You can also restart a running service and force it to reread
its configuration file by using:</p>
<example>
httpd.exe -k restart -n "MyServiceName"
</example>
<p>By default, all Apache services are registered to run as the
system user (the <code>LocalSystem</code> account). The
<code>LocalSystem</code> account has no privileges to your network
via any Windows-secured mechanism, including the file system, named
pipes, DCOM, or secure RPC. It has, however, wide privileges locally.
</p>
<note type="warning"><strong>Never grant any network privileges to
the <code>LocalSystem</code> account! If you need Apache to be able
to access network resources, create a separate account for Apache as
noted below.</strong></note>
<p>It is recommended that users create a separate account for running
Apache service(s). If you have to access network resources via Apache,
this is required.</p>
<ol>
<li>Create a normal domain user account, and be sure to
memorize its password.</li>
<li>Grant the newly-created user a privilege of <code>Log on
as a service</code> and <code>Act as part of the operating
system</code>. On Windows NT 4.0 these privileges are granted via
User Manager for Domains, but on Windows 2000 and XP you probably
want to use Group Policy for propagating these settings. You can
also manually set these via the Local Security Policy MMC snap-in.
</li>
<li>Confirm that the created account is a member of the Users
group.</li>
<li>Grant the account read and execute (RX) rights to all document
and script folders (<code>htdocs</code> and <code>cgi-bin</code>
for example).</li>
<li>Grant the account change (RWXD) rights to the
Apache <code>logs</code> directory.</li>
<li>Grant the account read and execute (RX) rights to the
<code>httpd.exe</code> binary executable.</li>
</ol>
<note>It is usually a good practice to grant the user the Apache
service runs as read and execute (RX) access to the whole Apache2.&httpd.minor;
directory, except the <code>logs</code> subdirectory, where the
user has to have at least change (RWXD) rights.</note>
<p>If you allow the account to log in as a user and as a service,
then you can log on with that account and test that the account has
the privileges to execute the scripts, read the web pages, and that
you can start Apache in a console window. If this works, and you
have followed the steps above, Apache should execute as a service
with no problems.</p>
<note><strong>Error code 2186</strong> is a good indication that
you need to review the "Log On As" configuration for the service,
since Apache cannot access a required network resource. Also, pay
close attention to the privileges of the user Apache is
configured to run as.</note>
<p>When starting Apache as a service you may encounter an error
message from the Windows Service Control Manager. For example,
if you try to start Apache by using the Services applet in the
Windows Control Panel, you may get the following message:</p>
<example>
Could not start the Apache2.&httpd.minor; service on \\COMPUTER <br />
Error 1067; The process terminated unexpectedly.
</example>
<p>You will get this generic error if there is any problem with
starting the Apache service. In order to see what is really causing
the problem you should follow the instructions for Running Apache
for Windows from the Command Prompt.</p>
<p>If you are having problems with the service, it is suggested
you follow the instructions below to try starting httpd.exe from
a console window, and work out the errors before struggling to
start it as a service again.</p>
</section>
<section id="wincons">
<title>Running Apache as a Console Application</title>
<p>Running Apache as a service is usually the recommended way to
use it, but it is sometimes easier to work from the command line,
especially during initial configuration and testing.</p>
<p>To run Apache from the command line as a console application,
use the following command:</p>
<example>
httpd.exe
</example>
<p>Apache will execute, and will remain running until it is stopped
by pressing Control-C.</p>
<p>You can also run Apache via the shortcut Start Apache in Console
placed to <code>Start Menu --&gt; Programs --&gt; Apache HTTP Server
2.&httpd.minor;.xx --&gt; Control Apache Server</code> during the installation.
This will open a console window and start Apache inside it. If you
don't have Apache installed as a service, the window will remain
visible until you stop Apache by pressing Control-C in the console
window where Apache is running in. The server will exit in a few
seconds. However, if you do have Apache installed as a service, the
shortcut starts the service. If the Apache service is running
already, the shortcut doesn't do anything.</p>
<p>If Apache is running as a service, you can tell it to stop by opening another console
window and entering:</p>
<example>
httpd.exe -k shutdown
</example>
<p>Running as a service should be preferred over running in a
console window because this lets Apache end any current operations
and clean up gracefully.</p>
<p>But if the server is running in a console window, you can
only stop it by pressing Control-C in the same window.</p>
<p>You can also tell Apache to restart. This forces it to reread
the configuration file. Any operations in progress are allowed to
complete without interruption. To restart Apache, either press
Control-Break in the console window you used for starting Apache,
or enter</p>
<example>
httpd.exe -k restart
</example>
<p>if the server is running as a service.</p>
<note>Note for people familiar with the Unix version of Apache:
these commands provide a Windows equivalent to <code>kill -TERM
<em>pid</em></code> and <code>kill -USR1 <em>pid</em></code>. The
command line option used, <code>-k</code>, was chosen as a reminder
of the <code>kill</code> command used on Unix.</note>
<p>If the Apache console window closes immediately or unexpectedly
after startup, open the Command Prompt from the Start Menu --&gt;
Programs. Change to the folder to which you installed Apache, type
the command <code>httpd.exe</code>, and read the error message. Then
change to the logs folder, and review the <code>error.log</code>
file for configuration mistakes. Assuming httpd was installed into
<code>C:\Program Files\Apache Software Foundation\Apache2.&httpd.minor;\</code>,
you can do the following:</p>
<example>
c: <br />
cd "\Program Files\Apache Software Foundation\Apache2.&httpd.minor;\bin" <br />
httpd.exe
</example>
<p>Then wait for Apache to stop, or press Control-C. Then enter the
following:</p>
<example>
cd ..\logs <br />
more &lt; error.log
</example>
<p>When working with Apache it is important to know how it will
find the configuration file. You can specify a configuration file
on the command line in two ways:</p>
<ul>
<li><p><code>-f</code> specifies an absolute or relative path to
a particular configuration file:</p>
<example>
httpd.exe -f "c:\my server files\anotherconfig.conf"
</example>
<p>or</p>
<example>
httpd.exe -f files\anotherconfig.conf
</example></li>
<li><p><code>-n</code> specifies the installed Apache service
whose configuration file is to be used:</p>
<example>
httpd.exe -n "MyServiceName"
</example>
</li>
</ul>
<p>In both of these cases, the proper
<directive module="core">ServerRoot</directive> should be set in
the configuration file.</p>
<p>If you don't specify a configuration file with <code>-f</code>
or <code>-n</code>, Apache will use the file name compiled into the
server, such as <code>conf\httpd.conf</code>. This built-in path
is relative to the installation directory. You can verify the compiled
file name from a value labelled as <code>SERVER_CONFIG_FILE</code> when
invoking Apache with the <code>-V</code> switch, like this:</p>
<example>
httpd.exe -V
</example>
<p>Apache will then try to determine its <directive module="core"
>ServerRoot</directive> by trying the following, in this order:</p>
<ol>
<li>A <directive module="core">ServerRoot</directive> directive
via the <code>-C</code> command line switch.</li>
<li>The <code>-d</code> switch on the command line.</li>
<li>Current working directory.</li>
<li>A registry entry which was created if you did a binary
installation.</li>
<li>The server root compiled into the server. This is <code>
/apache</code> by default, you can verify it by using <code>
httpd.exe -V</code> and looking for a value labelled as
<code>HTTPD_ROOT</code>.</li>
</ol>
<p>If you did not do a binary install, Apache will in some
scenarios complain about the missing registry key. This warning can
be ignored if the server was otherwise able to find its
configuration file.</p>
<p>The value of this key is the
<directive module="core">ServerRoot</directive> directory which
contains the <code>conf</code> subdirectory. When Apache starts it
reads the <code>httpd.conf</code> file from that directory. If
this file contains a <directive module="core">ServerRoot</directive>
directive which contains a different directory from the one
obtained from the registry key above, Apache will forget the
registry key and use the directory from the configuration file. If
you copy the Apache directory or configuration files to a new
location it is vital that you update the
<directive module="core">ServerRoot</directive> directive in the
<code>httpd.conf</code> file to reflect the new location.</p>
</section>
<section id="test">
<title>Testing the Installation</title>
<p>After starting Apache (either in a console window or as a
service) it will be listening on port 80 (unless you changed the
<directive module="mpm_common">Listen</directive> directive in the
configuration files or installed Apache only for the current user).
To connect to the server and access the default page, launch a
browser and enter this URL:</p>
<example>
http://localhost/
</example>
<p>Apache should respond with a welcome page and you should see
"It Works!". If nothing happens or you get an error, look in the
<code>error.log</code> file in the <code>logs</code> subdirectory.
If your host is not connected to the net, or if you have serious
problems with your DNS (Domain Name Service) configuration, you
may have to use this URL:</p>
<example>
http://127.0.0.1/
</example>
<p>If you happen to be running Apache on an alternate port, you
need to explicitly put that in the URL:</p>
<example>
http://127.0.0.1:8080/
</example>
<p>Once your basic installation is working, you should configure it
properly by editing the files in the <code>conf</code> subdirectory.
Again, if you change the configuration of the Windows NT service
for Apache, first attempt to start it from the command line to
make sure that the service starts with no errors.</p>
<p>Because Apache <strong>cannot</strong> share the same port with
another TCP/IP application, you may need to stop, uninstall or reconfigure
certain other services before running Apache. These conflicting
services include other WWW servers, some firewall implementations,
and even some client applications (such as Skype) which will use port
80 to attempt to bypass firewall issues.</p>
</section>
<section id="windrivemap">
<title>Configuring Access to Network Resources</title>
<p>Access to files over the network can be specified using two
mechanisms provided by Windows:</p>
<dl>
<dt>Mapped drive letters</dt>
<dd>e.g., <code>Alias /images/ Z:/</code></dd>
<dt>UNC paths</dt>
<dd>e.g., <code>Alias /images/ //imagehost/www/images/</code></dd>
</dl>
<p>Mapped drive letters allow the administrator to maintain the
mapping to a specific machine and path outside of the Apache httpd
configuration. However, these mappings are associated only with
interactive sessions and are not directly available to Apache httpd
when it is started as a service. <strong>Use only UNC paths for
network resources in httpd.conf</strong> so that the resources can
be accessed consistently regardless of how Apache httpd is started.
(Arcane and error prone procedures may work around the restriction
on mapped drive letters, but this is not recommended.)</p>
<example><title>Example DocumentRoot with UNC path</title>
<highlight language="config">
DocumentRoot //dochost/www/html/
</highlight>
</example>
<example><title>Example DocumentRoot with IP address in UNC path</title>
<highlight language="config">
DocumentRoot //192.168.1.50/docs/
</highlight>
</example>
<example><title>Example Alias and corresponding Directory with UNC path</title>
<highlight language="config">
Alias /images/ //imagehost/www/images/
&lt;Directory //imagehost/www/images/&gt;
#...
&lt;Directory&gt;
</highlight>
</example>
<p>When running Apache httpd as a service, you must create a
separate account in order to access network resources, as described
above.</p>
</section>
</manualpage>