<
H2><
A NAME="inst">Installing Apache for Windows</
A></
H2>
Run the Apache <
SAMP>.exe</
SAMP> file you downloaded above. This will
<
LI>the directory to install Apache into (the default is
<
CODE>\Program Files\Apache Group\Apache</
CODE> although you can
change this to any other directory)
<
LI>the start menu name (default is "Apache Web Server")
<
LI>the installation type. The "Typical" option installs
everything except the source code. The "Minimum" option does not
install the manuals or source code. Choose the "Custom" install if
you want to install the source code.
During the installation, Apache will configure the files in the
<
SAMP>conf</
SAMP> directory for your chosen installation
directory. However if any of the files in this directory already exist
they will <
STRONG>not</
STRONG> be overwritten. Instead the new copy of
the corresponding file will be left with the extension
<
SAMP>.default</
SAMP>. So, for example, if
<
SAMP>conf\
httpd.conf</
SAMP> already exists it will not be altered,
but the version which would have been installed will be left in
finished you should manually check to see what in new in the
<
SAMP>.default</
SAMP> file, and if necessary update your existing
Also, if you already have a file called <
SAMP>htdocs\
index.html</
SAMP>
file will be installed either). This should mean it a safe to install
Apache over an existing installation (but you will have to stop the
existing server running before doing the installation, then start the
new one after the installation is finished).
After installing Apache, you should edit the configuration files in
the <
SAMP>conf</
SAMP> directory as required. These files will be
configured during the install ready for Apache to be run from the
directory where it was installed, with the documents served from the
subdirectory <
SAMP>htdocs</
SAMP>. There are lots of other options
which should be set before you start really using Apache. However to
get started quickly the files should work as installed.
<
H2><
A NAME="run">Running Apache for Windows</
A></
H2>
There are two ways you can run Apache:
<
LI>As a <
A HREF="#service">"service"</
A> (available on NT only). This is the best option if
you want Apache to automatically start when you machine boots, and to
keep Apache running when you log-off.
<
LI>From a <
A HREF="#cmdline">console window</
A>. This is the only option
To start Apache as a service, you first need to install it as a
service. Multiple Apache services can be installed, each with a
different name and configuration. To install the default Apache
service named "Apache", run the "Install Apache as Service (NT only)"
option from the Start menu. Once this is done you can start the "Apache"
service by opening the Services window (in the Control Panel), selecting Apache,
then clicking on Start. Apache will now be running in the background. You
can later stop Apache by clicking on Stop. As an alternative to using
the Services window, you can start and stop the "Apache" service from the control
See <
A HREF="#signalsrv">Signalling Service Apache when Running</
A>
for more information on installing and controlling Apache services.
To run Apache from a console window, select the "Start Apache as
console app" option from the Start menu (in Apache 1.3.4 and earlier,
this option was called "Apache Server"). This will open a console
window and start Apache running inside it. The window will remain
active until you stop Apache. To stop Apache running, either select
the "Shutdown Apache console app" icon option from the Start menu
(this is not available in Apache 1.3.4 or earlier), or see <
AHREF="#signal">Signalling Console Apache when Running</
A> for how
to control Apache from the command line.
After starting Apache running (either in a console window or as a
service) if will be listening to port 80 (unless you changed the
<
SAMP>Port</
SAMP>, <
SAMP>Listen</
SAMP> or <
SAMP>BindAddress</
SAMP>
directives in the configuration files). To connect to the server and
access the default page, launch a browser and enter this URL:
This should respond with a welcome page, and a link to the Apache
manual. If nothing happens or you get an error, look in the
<
SAMP>error_log</
SAMP> file in the <
SAMP>logs</
SAMP> directory.
If your host isn't connected to the net, you may have to use
Once your basic installation is working, you should configure it
properly by editing the files in the <
SAMP>conf</
SAMP> directory.
<
H2><
A NAME="use">Configuring Apache for Windows</
A></
H2>
Apache is configured by files in the <
SAMP>conf</
SAMP>
directory. These are the same as files used to configure the Unix
version, but there are a few different directives for Apache on
Windows. See the <
A HREF="./">Apache documentation</
A> for all the
The main differences in Apache for Windows are:
<
LI><
P>Because Apache for Windows is multithreaded, it does not use a
separate process for each request, as Apache does with
Unix. Instead there are usually only two Apache processes running:
a parent process, and a child which handles the requests. Within
the child each request is handled by a separate thread.
So the "process"-management directives are different:
HREF="mod/core.html#maxrequestsperchild">MaxRequestsPerChild</
A>
- Like the Unix directive, this controls how many requests a
process will serve before exiting. However, unlike Unix, a
process serves all the requests at once, not just one, so if
this is set, it is recommended that a very high number is
used. The recommended default, <
CODE>MaxRequestsPerChild
0</
CODE>, does not cause the process to ever exit.
<
P><
A HREF="mod/core.html#threadsperchild">ThreadsPerChild</
A> -
This directive is new, and tells the server how many threads it
should use. This is the maximum number of connections the server
can handle at once; be sure and set this number high enough for
your site if you get a lot of hits. The recommended default is
<
CODE>ThreadsPerChild 50</
CODE>.</
P>
<
LI><
P>The directives that accept filenames as arguments now must use
Windows filenames instead of Unix ones. However, because Apache
uses Unix-style names internally, you must use forward slashes, not
backslashes. Drive letters can be used; if omitted, the drive with
the Apache executable will be assumed.</
P>
<
LI><
P>Apache for Windows contains the ability to load modules at runtime,
without recompiling the server. If Apache is compiled normally, it
will install a number of optional modules in the
<
CODE>\Apache\modules</
CODE> directory. To activate these, or other
directive must be used. For example, to active the status module,
use the following (in addition to the status-activating directives
<
P>Information on <
A HREF="mod/mod_so.html#creating">creating loadable
modules</
A> is also available.</
P>
<
LI><
P>Apache can also load ISAPI Extensions (<
EM>
i.e.</
EM>, Internet Server
Applications), such as those used by Microsoft's IIS, and other
<
H2><
A NAME="service">Running Apache for Windows as a Service</
A></
H2>
<
STRONG>Note: The -n option to specify a service name is only available
with Apache 1.3.7 and later. Earlier versions of Apache only support
the default service name 'Apache'.</
STRONG>
You can install Apache as a Windows NT service as follows:
apache -i -n "service name"
To install a service to use a particular configuration, specify the
configuration file when the service is installed:
apache -i -n "service name" -f "\my server\conf\
my.conf"
To remove an Apache service, use
apache -u -n "service name"
The default "service name", if one is not specified, is "Apache".
Once a service is installed, you can use the <
SAMP>-n</
SAMP> option, in conjunction
with other options, to refer to a service's configuration file. For example:<
br>
To test a service's configuration file:
apache -n "service name" -t
To start a console Apache using a service's configuration file:
<
H2><
A NAME="cmdline">Running Apache for Windows from the Command Line</
A></
H2>
The Start menu icons and the NT Service manager can provide a simple
interface for administering Apache. But in some cases it is easier to
work from the command line.
When working with Apache it is important to know how it will find the
configuration files. You can specify a configuration file on the command line
<
LI>-f specifies a path to a particular configuration file
<
PRE> apache -f "c:\my server\conf\
my.conf"</
PRE>
<
LI>-n specifies the configuration file of an installed Apache service (Apache 1.3.7 and later)
<
PRE> apache -n "service name"</
PRE>
In these cases, the proper ServerRoot should be set in the configuration file.
If you don't specify a configuration file name with -f or -n, Apache will
use the file name compiled into the server, usually "
conf/
httpd.conf". Invoking
Apache with the -V switch will display this value labeled as SERVER_CONFIG_FILE.
Apache will then determine its ServerRoot by trying the following, in this order:
<
LI>A ServerRoot directive via a -C switch.
<
LI>The -d switch on the command line.
<
LI>Current working directory
<
LI>A registry entry, created if you did a binary install.
<
LI>The server root compiled into the server.
The server root compiled into the server is usually "/apache".
invoking apache with the -V switch will display this value
When invoked from the start menu, Apache is usually passed no arguments,
so using the registry entry is the preferred technique for console Apache.
During a binary installation, a registry key will have
been installed, for example:
HKEY_LOCAL_MACHINE\Software\Apache Group\Apache\1.3.4\ServerRoot
This key is compiled into the server and can enable you to test
new versions without affecting the current version. Of course
you must take care not to install the new version on top of the
old version in the file system.
If you did not do a binary install then Apache will in some
scenarios complain that about the missing registry key. This
warning can be ignored if it otherwise was able to find its
The value of this key is the "ServerRoot" directory, containing the
<
SAMP>conf</
SAMP> directory. When Apache starts it will read the
<
SAMP>
httpd.conf</
SAMP> file from this directory. If this file
contains a <
SAMP>ServerRoot</
SAMP> directive which is different from
the directory 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 <
SAMP>ServerRoot</
SAMP>
directory in the <
SAMP>
httpd.conf</
SAMP> file to the new location.
To run Apache from the command line as a console application, use the
Apache will execute, and will remain running until it is stopped by pressing
<
H2><
A NAME="signalsrv">Signalling Service Apache when running</
A></
H2>
On Windows NT, multiple instances of Apache can be run as services.
Signal an Apache service to start, restart, or shutdown as follows:
apache -n "service name" -k start
apache -n "service name" -k restart
apache -n "service name" -k shutdown
In addition, you can use the native NT NET command to
start and stop Apache services as follows:
<
H2><
A NAME="signal">Signalling Console Apache when running</
A></
H2>
On Windows 95, Apache runs as a console application. You can tell a
running Apache to stop by opening another console window and running
<
STRONG>Note: This option is only available with Apache 1.3.3 and
later. For earlier versions, you need to use Control-C in the
Apache console window to shut down the server.</
STRONG>
This should be used instead of pressing Control-C in the running
Apache console window, because it lets Apache end any current
transactions and cleanup gracefully.
You can also tell Apache to restart. This makes it re-read the
configuration files. Any transactions in progress are allowed to
complete without interruption. To restart Apache, run
<
STRONG>Note: This option is only available with Apache 1.3.3 and
later. For earlier versions, you need to use Control-C in the
Apache console window to shut down the server.</
STRONG>
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
"kill" command used on Unix.
<
H2><
A NAME="comp">Compiling Apache for Windows</
A></
H2>
<
P>Compiling Apache requires Microsoft Visual C++ 5.0 to be properly
installed. It is easiest to compile with the command-line tools
(nmake, <
EM>etc.</
EM>..). Consult the VC++ manual to determine how to install
<
P>First, unpack the Apache distribution into an appropriate
directory. Open a command-line prompt, and change to the
<
CODE>src</
CODE> subdirectory of the Apache distribution.</
P>
<
P>The master Apache makefile instructions are contained in the
<
CODE>
Makefile.nt</
CODE> file. To compile Apache on Windows NT, simply
use one of the following commands:
<
LI><
CODE>nmake /f
Makefile.nt _apacher</
CODE> (release build)
<
LI><
CODE>nmake /f
Makefile.nt _apached</
CODE> (debug build)
<
P><
em>(1.3.4 and later)</
em> To compile Apache on Windows 95, use one of
<
P>These will both compile Apache. The latter will include debugging
information in the resulting files, making it easier to find bugs and
<
P>Apache can also be compiled using VC++'s Visual Studio development
environment. Although compiling Apache in this manner is not as
simple, it makes it possible to easily modify the Apache source, or
to compile Apache if the command-line tools are not installed.
Project files (<
CODE>.DSP</
CODE>) are included for each of the
portions of Apache. To build Apache from the these projects files
you will need to build the following projects <
EM>in this order</
EM>:
In addition, the <
CODE>src\os\win32</
CODE> subdirectory contains
project files for the optional modules (see below).</
P>
<
P>Once Apache has been compiled, it needs to be installed in its server
root directory. The default is the <
CODE>\Apache</
CODE>
directory, on the current hard drive. </
P>
<
P>To install the files into the <
CODE>\Apache</
CODE> directory
automatically, use one the following nmake commands (see above):</
P>
<
LI><
CODE>nmake /f
Makefile.nt installr INSTDIR=<
EM>dir</
EM></
CODE>
<
LI><
CODE>nmake /f
Makefile.nt installd INSTDIR=<
EM>dir</
EM></
CODE>
or, for Windows 95 (1.3.4 and later), use one of:
The dir argument to INSTDIR gives the installation directory; it can
be omitted if Apache is to be installed into <
SAMP>\Apache</
SAMP>.
<
P>This will install the following:</
P>
<
LI><
CODE><
EM>dir</
EM>\
Apache.exe</
CODE> - Apache executable
<
LI><
CODE><
EM>dir</
EM>\
ApacheCore.dll</
CODE> - Main Apache shared library
<
LI><
CODE><
EM>dir</
EM>\modules\ApacheModule*.dll</
CODE> - Optional Apache
<
LI><
CODE><
EM>dir</
EM>\conf</
CODE> - Empty configuration directory
<
LI><
CODE><
EM>dir</
EM>\logs</
CODE> - Empty logging directory
<
P>If you do not have nmake, or wish to install in a different directory,
be sure to use a similar naming scheme.</
P>
Before running the server you must fill out the conf directory.
Copy the *.conf-dist-win from the distribution conf directory
and rename *.conf. Edit the @@ServerRoot@@ entries to your
actual server root (for example "C:\apache"). Copy over