From cbf9ea75078e093d15667a848c80268524b54a8e Mon Sep 17 00:00:00 2001
From: Astrid Kessler Apache HTTP Server Version 2.1 Apache can be run as a service on Windows NT/2000. (There is
- also some HIGHLY EXPERIMENTAL support for similar behavior on
- Windows 95/98, introduced with Apache
- 1.3.13). Installing Apache as a service should only be done once you
- can successfully run it in a console window. See Using Apache with Microsoft Windows
- before you attempt to install or run Apache as a service.
- Changes to the 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, hidden 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 command line with See Controlling Apache as a Service
- for more information on installing and controlling Apache
- services. After starting Apache as a service (or if you have trouble
- starting it) you can test it using the same procedure as for running in a
- console window. Remember to use the command: to assure you are using the service's configuration. You can install Apache as a Windows NT service as
- follows: To install a service to use a particular configuration,
- specify the configuration file when the service is
- installed: To remove an Apache service, use: The default "service name", if one is not specified, is
- "Apache". Once a service is installed, you can use the To test a service's configuration file: To start a console Apache using a service's configuration
- file: Prior to Apache release 1.3.13, the dependencies required to
- successfully start an installed service were not configured.
- After installing a service using earlier versions of Apache,
- you must follow these steps: If you are using COM or DCOM components from a third party
- module, ISAPI, or other add-in scripting technologies such as
- ActiveState Perl, you may also need to add the entry Rpcss to
- the DependOnService list. To avoid exposing the TCP port 135
- when it is unnecessary, Apache does not create that entry upon
- installation. Follow the directions above to find or create the
- DependOnService value, double click that value if it already
- exists, and add the Rpcss entry to the list. When Apache is first installed as a service (e.g. with the
- NEVER grant network privileges to the SYSTEM
- account! Create a new user account instead, grant the
- appropriate privileges to that user, and use the the "Log On
- As:" option. Select the Start Menu -> Settings -> Control
- Panel -> Services -> apache service ... and click the
- "Startup" button to access this setting. The SYSTEM account has no privileges to the network, so
- shared pages or a shared installation of Apache is invisible to
- the service. If you intend to use any network
- resources, the following steps should help: If you allow the account to log in as a user, then you can
- log in yourself 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. When starting Apache as a service you may encounter an error
- message from Windows service manager. For example if you try to
- start Apache using the Services applet in Windows Control Panel
- you may get the following message: You will get this error if there is any problem starting
- Apache. In order to see what is causing the problem you should
- follow the instructions for Running Apache for Windows from the
- Command Line. Also, Apache 1.3.13 now records startup errors in the
- Application Event Log under Windows NT/2000, if Apache is run
- as a service. Run the Event Viewer and select Log ...
- Application to see these events. For details on controlling Apache service from the command
- line, please refer to console
- command line section. Multiple instances of Apache can be installed and run as
- services. Signal an installed Apache service to start, restart,
- or shutdown/stop as follows: For the default "Apache" service, the In addition, you can use the native NT Again, quotes are only required if the service name contains
- spaces. There is some support for Apache on Windows 95/98 to behave
- in a similar manner as a service on Windows NT/2000. It is
- highly experimental, if it works (at all) the Apache
- Sofware Foundation will not attest to its reliability or
- future support. Proceed at your own risk! Once you have confirmed that Apache runs correctly at the Command Prompt you can install,
- control and uninstall it with the same commands as the Windows
- NT/2000 version. There are, however, significant differences that you should
- note: Apache will attempt to start and if successful it will run
- in the background. If you run the command via a shortcut on your desktop, for example, then if the
- service starts successfully a console window will flash up but
- immediately disappears. If Apache detects any errors on startup
- such as a incorrect entries in the Windows 95/98 does not support Apache and Windows 95/98 offer no support for running the
- Apache service as a specific user with network privileges. In
- fact, Windows 95/98 offers no security on the local machine,
- either. This is the simple reason that the Apache Software
- Foundation never endorses the use of Windows 95/98 as a public
- httpd server. These facilities exist only to assist the user in
- developing web content and learning the Apache server, and
- perhaps as a intranet server on a secured, private network. Apache can be run as a service on Windows NT/2000. (There is
- also some HIGHLY EXPERIMENTAL support for similar behavior on
- Windows 95/98, introduced with Apache
- 1.3.13). Installing Apache as a service should only be done once you
- can successfully run it in a console window. See Using Apache with Microsoft Windows
- before you attempt to install or run Apache as a service.
- Changes to the 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, hidden 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 command line with See Controlling Apache as a Service
- for more information on installing and controlling Apache
- services. After starting Apache as a service (or if you have trouble
- starting it) you can test it using the same procedure as for running in a
- console window. Remember to use the command: to assure you are using the service's configuration. You can install Apache as a Windows NT service as
- follows: To install a service to use a particular configuration,
- specify the configuration file when the service is
- installed: To remove an Apache service, use: The default "service name", if one is not specified, is
- "Apache". Once a service is installed, you can use the To test a service's configuration file: To start a console Apache using a service's configuration
- file: Prior to Apache release 1.3.13, the dependencies required to
- successfully start an installed service were not configured.
- After installing a service using earlier versions of Apache,
- you must follow these steps: If you are using COM or DCOM components from a third party
- module, ISAPI, or other add-in scripting technologies such as
- ActiveState Perl, you may also need to add the entry Rpcss to
- the DependOnService list. To avoid exposing the TCP port 135
- when it is unnecessary, Apache does not create that entry upon
- installation. Follow the directions above to find or create the
- DependOnService value, double click that value if it already
- exists, and add the Rpcss entry to the list. When Apache is first installed as a service (e.g. with the
- NEVER grant network privileges to the SYSTEM
- account! Create a new user account instead, grant the
- appropriate privileges to that user, and use the the "Log On
- As:" option. Select the Start Menu -> Settings -> Control
- Panel -> Services -> apache service ... and click the
- "Startup" button to access this setting. The SYSTEM account has no privileges to the network, so
- shared pages or a shared installation of Apache is invisible to
- the service. If you intend to use any network
- resources, the following steps should help: If you allow the account to log in as a user, then you can
- log in yourself 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. When starting Apache as a service you may encounter an error
- message from Windows service manager. For example if you try to
- start Apache using the Services applet in Windows Control Panel
- you may get the following message: You will get this error if there is any problem starting
- Apache. In order to see what is causing the problem you should
- follow the instructions for Running Apache for Windows from the
- Command Line. Also, Apache 1.3.13 now records startup errors in the
- Application Event Log under Windows NT/2000, if Apache is run
- as a service. Run the Event Viewer and select Log ...
- Application to see these events. For details on controlling Apache service from the command
- line, please refer to console
- command line section. Multiple instances of Apache can be installed and run as
- services. Signal an installed Apache service to start, restart,
- or shutdown/stop as follows: For the default "Apache" service, the In addition, you can use the native NT Again, quotes are only required if the service name contains
- spaces. There is some support for Apache on Windows 95/98 to behave
- in a similar manner as a service on Windows NT/2000. It is
- highly experimental, if it works (at all) the Apache
- Sofware Foundation will not attest to its reliability or
- future support. Proceed at your own risk! Once you have confirmed that Apache runs correctly at the Command Prompt you can install,
- control and uninstall it with the same commands as the Windows
- NT/2000 version. There are, however, significant differences that you should
- note: Apache will attempt to start and if successful it will run
- in the background. If you run the command via a shortcut on your desktop, for example, then if the
- service starts successfully a console window will flash up but
- immediately disappears. If Apache detects any errors on startup
- such as a incorrect entries in the Windows 95/98 does not support Apache and Windows 95/98 offer no support for running the
- Apache service as a specific user with network privileges. In
- fact, Windows 95/98 offers no security on the local machine,
- either. This is the simple reason that the Apache Software
- Foundation never endorses the use of Windows 95/98 as a public
- httpd server. These facilities exist only to assist the user in
- developing web content and learning the Apache server, and
- perhaps as a intranet server on a secured, private network. This document explains how to install, configure and run
Apache 2.0 under Microsoft Windows. If you find any bugs, or
- wish to contribute in other ways, please use our bug reporting page. Most of this document assumes that you are installing
- Windows from a binary distribution. If you want to compile
- Apache yourself (possibly to help with development, or to track
- down bugs), see Compiling Apache
- for Microsoft Windows. Abbreviations and their meanings used in this
- document include:Running Apache for Windows as a Service
-
- httpd.conf
file should always be
- followed by starting Apache as a console window. If this
- succeeds, the service should succeed.-u
) and re-installing
- (-i
) the Apache service.
- NET START APACHE
- NET STOP APACHE
- Note
- Apache, unlike many other Windows NT/2000 services,
- logs any errors to its own error.log file in the logs folder
- within the Apache server root folder. You will not
- find Apache error details in the Windows NT Event
- Log.
- apache -n "service name"
-
Running Apache for Windows as a Service
-
-
-
- -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".
- apache -i -n "service name"
-
- apache -i -n "service name" -f "\my server\conf\my.conf"
-
- apache -u -n "service name"
-
-n
- option, in conjunction with other options, to refer to a
- service's configuration file. For example:
- apache -n "service name" -t
-
- apache -n "service name"
-
Important Note on service dependencies:
-
-
-
-
- Run regedt32
- Select Window - "HKEY_LOCAL_MACHINE on Local Machine" from the menu
- Double-click to open the SYSTEM, then the CurrentControlSet keys
- Scroll down and click on the Apache servicename
- Select Edit - Add Value... from the menu
- Fill in the Add Value dialog with
- Value Name: DependOnGroup
- Data Type: REG_MULTI_SZ
- and click OK
- Leave the Multi-String Editor dialog empty and click OK
- Select Edit - Add Value... from the menu
- Fill in the Add Value dialog with
- Value Name: DependOnService
- Data Type: REG_MULTI_SZ
- and click OK
- Type the following list (one per line) in the Multi-String Editor dialog
- Tcpip
- Afd
- and click OK
- User Account for Apache Service to Run As (NT/2000)
-
-
-
- -i
option) it will run as user "System" (the LocalSystem
- account). There should be few issues if all resources for the
- web server reside on the local system, but it has broad
- security privileges to affect the local machine!
-
-
-
-
- document
and script
- directories (minimally read and browse access).logs
directory!Troubleshooting Apache for Windows as a Service
-
-
-
-
- Could not start the apache service on \\COMPUTER
- Error 1067; The process terminated unexpectedly.
- Running Apache for Windows from the Command Line
-
-
-
- Controlling Apache as a Service
-
-
-
-
- apache -n "service name" -k start
- apache -n "service name" -k restart
- apache -n "service name" -k shutdown
- apache -n "service name" -k stop
- -n
Apache
- option is still required, since the -k
commands without
- the -n
option are directed at Apache running in a console
- window. The quotes are only required if the service name contains spaces.-k stop
alias for the
- -k shutdown
command was introduced in Apache version
- 1.3.13. Earlier versions of Apache will only recognize the
- -k shutdown
option. Prior to 1.3.3, Apache did not
- recognize any -k
options at all!NET
command
- to start and stop Apache services as follows:
- NET START "service name"
- NET STOP "service name"
- HIGHLY EXPERIMENTAL Windows 95/98 Service
-
-
-
-
- Apache -n "service name" -k start
-
httpd.conf
file,
- then the console window will remain visible. This will display
- an error message which will be useful in tracking down the cause
- of the problem.NET START
or
- NET STOP
commands so you must use Apache's Service
- Control options at a command prompt. You may wish to set up a
- shortcut for each of these commands so that you can just choose
- it from the start menu or desktop to perform the required action.httpd.conf
file should always be
- followed by starting Apache as a console window. If this
- succeeds, the service should succeed.-u
) and re-installing
- (-i
) the Apache service.
- NET STOP APACHE
- -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".-n
- option, in conjunction with other options, to refer to a
- service's configuration file. For example:
- Select Window - "HKEY_LOCAL_MACHINE on Local Machine" from the menu
- Double-click to open the SYSTEM, then the CurrentControlSet keys
- Scroll down and click on the Apache servicename
- Select Edit - Add Value... from the menu
- Fill in the Add Value dialog with
- Value Name: DependOnGroup
- Data Type: REG_MULTI_SZ
- and click OK
- Leave the Multi-String Editor dialog empty and click OK
- Select Edit - Add Value... from the menu
- Fill in the Add Value dialog with
- Value Name: DependOnService
- Data Type: REG_MULTI_SZ
- and click OK
- Type the following list (one per line) in the Multi-String Editor dialog
- Tcpip
- Afd
- and click OK
- -i
option) it will run as user "System" (the LocalSystem
- account). There should be few issues if all resources for the
- web server reside on the local system, but it has broad
- security privileges to affect the local machine!
-
-
-
-
- document
and script
- directories (minimally read and browse access).logs
directory!
- Error 1067; The process terminated unexpectedly.
-
- apache -n "service name" -k restart
- apache -n "service name" -k shutdown
- apache -n "service name" -k stop
- -n
Apache
- option is still required, since the -k
commands without
- the -n
option are directed at Apache running in a console
- window. The quotes are only required if the service name contains spaces.-k stop
alias for the
- -k shutdown
command was introduced in Apache version
- 1.3.13. Earlier versions of Apache will only recognize the
- -k shutdown
option. Prior to 1.3.3, Apache did not
- recognize any -k
options at all!NET
command
- to start and stop Apache services as follows:
- NET STOP "service name"
- httpd.conf
file,
- then the console window will remain visible. This will display
- an error message which will be useful in tracking down the cause
- of the problem.NET START
or
- NET STOP
commands so you must use Apache's Service
- Control options at a command prompt. You may wish to set up a
- shortcut for each of these commands so that you can just choose
- it from the start menu or desktop to perform the required action.
This document assumes that you are installing a binary + distribution of Apache. If you want to compile Apache yourself + (possibly to help with development or tracking down bugs), + see Compiling Apache for Microsoft + Windows.
+ +Because of the current versioning policies on Microsoft + Windows operating system families, this document assumes the + following:
At this time, support for Windows 9x is - incomplete. Apache 2.0 is not expected to work on those - platforms at this time. If you are interested in - helping with that effort, please see the developer's site for - information on how to get - involved. Support will likely be provided at some point in - the future, and patches to allow Apache to work on 9x are - welcome!
- -Apache 2.0 is designed to run on Windows NT 4.0 and Windows - 2000. The binary installer will only work with the x86 family - of processors, such as Intel's. Apache may also run on Windows - 9x, but it is not tested, and is never recommended for production - servers. In all cases TCP/IP networking must be installed.
+The primary Windows platform for running Apache 2.0 is Windows + NT. The binary installer only works with the x86 family of + processors, such as Intel and AMD processors. Running Apache on + Windows 9x is not thoroughly tested, and it is never recommended on + production systems. +
-If running on Windows 95, the "Winsock2" upgrade MUST BE - INSTALLED. "Winsock2" for Windows 95 is available here.
+On all operating systems, TCP/IP networking must be installed + and working. If running on Windows 95, the Winsock 2 upgrade must + be installed. Winsock 2 for Windows 95 can be downloaded from here. +
-If running on NT 4.0, installing Service Pack 6 is +
On Windows NT 4.0, installing Service Pack 6 is strongly recommended, as Service Pack 4 created known issues with TCP/IP - and WinSock integrity that were resolved in later Service - Packs.
- + and Winsock integrity that were resolved in later Service Packs.Information on the latest version of Apache can be found on - the Apache web server at http://httpd.apache.org/. - This will list the current release, any more recent alpha or - beta-test releases, together with details of mirror web and - anonymous ftp sites.
- -You should download the version of Apache for Windows with
- the .msi
extension. This is a single Microsoft
- Installer file containing Apache, ready to install and run.
- There is a seperate .zip
file containing only
- the source code, to compile Apache yourself with the Microsoft
- Visual C++ (Visual Studio) tools.
Information on the latest versions of Apache can be found on the + web site of the Apache web server at + http://httpd.apache.org/download.cgi. + There you will find the current release, as well as more recent alpha + or beta test versions, and a list of HTTP and FTP mirrors from which + you can download the Apache web server. Please use a mirror near to + you for a fast and reliable download.
+ +For Windows installations you should download the version of
+ Apache for Windows with the .msi
extension. This is a
+ single Microsoft Installer file, which contains a ready-to-run
+ version of Apache. There is a separate .zip
file,
+ which contains only the source code. You can compile Apache
+ yourself with the Microsoft Visual C++ (Visual Studio) tools.
You need Microsoft Installer 1.2 or above for the installation + to work. On Windows 9x you can update your Microsoft Installer to + version 2.0 here + and on Windows NT 4.0 and 2000 the version 2.0 update can be found + here. + Windows XP does not need this update.
+ +Note that you cannot install two versions of Apache 2.0 on the + same computer with the binary installer. You can, however, install + a version of the 1.3 series and a version of the + 2.0 series on the same computer without problems. If you need to + have two different 2.0 versions on the same computer, you have to + compile and install Apache from the + source.
+ +Run the Apache .msi
file you downloaded above. The
+ installation will ask you for these things:
Network Domain. Enter the DNS domain in which
+ your server is or will be registered in. For example, if your
+ server's full DNS name is server.mydomain.net
, you would
+ type mydomain.net
here.
Server Name. Your server's full DNS name.
+ From the example above, you would type server.mydomain.net
+ here.
Administrator's Email Address. Enter the + server administrator's or webmaster's email address here. This + address will be displayed along with error messages to the client + by default.
For whom to install Apache Select for
+ All Users, on Port 80, as a Service - Recommended
if you'd
+ like your new Apache to listen at port 80 for incoming traffic.
+ It will run as a service (that is, Apache will run even if no one
+ is logged in on the server at the moment) Select only for
+ the Current User, on Port 8080, when started Manually
if
+ you'd like to install Apache for your personal experimenting or
+ if you already have another WWW server running on port 80.
The installation type. Select Typical
+ for everything except the source code and libraries for module
+ development. With Custom
you can specify what to
+ install. A full install will require about 13 megabytes of free
+ disk space. This does not include the size of your web
+ site(s).
Where to install. The default path is
+ C:\Program Files\Apache Group
under which a directory
+ called Apache2
will be created by default.
During the installation, Apache will configure the files in the
+ conf
subdirectory to reflect the chosen installation
+ directory. However, if any of the configuration files in this
+ directory already exist, they will not be overwritten. Instead, the
+ new copy of the corresponding file will be left with the extension
+ .default
. So, for example, if conf\httpd.conf
+ already exists, it will be renamed as conf\httpd.conf.default
.
+ After the installation you should manually check to see what new
+ settings are in the .default
file, and if necessary,
+ update your existing configuration file.
Also, if you already have a file called htdocs\index.html
,
+ it will not be overwritten (and no index.html.default
+ will be installed either). This means it should be safe to install
+ Apache over an existing installation, although you would have to
+ stop the existing running server before doing the installation, and
+ then start the new one after the installation is finished.
After installing Apache, you must edit the configuration files
+ in the conf
subdirectory as required. These files
+ will be configured during the installation so that Apache is ready
+ to be run from the directory it was installed into, with the
+ documents server from the subdirectory htdocs
. There
+ are lots of other options which you should set before you really
+ start using Apache. However, to get started quickly, the files
+ should work as installed.
Run the Apache .msi
file you downloaded above.
- This will ask for:
Apache is configured by the files in the conf
+ subdirectory. These are the same files used to configure the Unix
+ version, but there are a few different directives for Apache on
+ Windows. See the directive index
+ for all the available directives.
The main differences in Apache for Windows are:
\Program Files\Apache Group\Apache
although you
- can change this to any other directory)Because Apache for Windows is multithreaded, it does not + use a separate process for each request, as Apache does on Unix. + Instead there are usually only two Apache processes running: a + parent process, and a child which handles the requests. Within + the child process each request is handled by a separate thread. +
+ +The process management directives are also different:
+ +MaxRequestsPerChild
:
+ Like the Unix directive, this controls how many requests a single
+ child process will serve before exiting. However, unlike on Unix,
+ a single process serves all the requests at once, not just one.
+ If this is set, it is recommended that a very high number is
+ used. The recommended default, MaxRequestsPerChild 0
,
+ causes the child process to never exit.
httpd.conf
, the new child may not start or
+ you may receive unexpected results.ThreadsPerChild
:
+ This directive is new. It tells the server how many threads it
+ should use. This is the maximum number of connections the server
+ can handle at once, so be sure to set this number high enough for
+ your site if you get a lot of hits. The recommended default is
+ ThreadsPerChild 50
.
The directives that accept filenames as arguments 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.
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
+ \Apache2\modules
directory. To activate these or
+ other modules, the new LoadModule
+ directive must be used. For example, to activate the status
+ module, use the following (in addition to the status-activating
+ directives in access.conf
):
+ LoadModule status_module modules/mod_status.so
+
Information on creating + loadable modules is also available.
Apache can also load ISAPI (Internet Server Application + Programming Interface) extensions (i.e. internet server + applications), such as those used by Microsoft IIS and other + Windows servers. More information + is available. Note that Apache cannot load + ISAPI Filters.
When running CGI scripts, the method Apache uses to find
+ the interpreter for the script is configurable using the
+ ScriptInterpreterSource
+ directive.
Since it is often difficult to manage files with names
+ like .htaccess
in Windows, you may find it useful to
+ change the name of this per-directory configuration file using
+ the AccessFilename
+ directive.
Any errors during Apache startup are logged into the
+ Windows event log when running on Windows NT. This mechanism
+ acts as a backup for those situations where Apache cannot even
+ access the normally used error.log
file. You can
+ view the Windows event log by using the Event Viewer application
+ on Windows NT 4.0, and the Event Viewer MMC snap-in on newer
+ versions of Windows.
During the installation, Apache will configure the files in
- the conf
directory for your chosen installation
- directory. However if any of the files in this directory
- already exist they will not be overwritten.
- Instead the new copy of the corresponding file will be left
- with the extension .default
. So, for example, if
- conf\httpd.conf
already exists it will not be
- altered, but the version which would have been installed will
- be left in conf\httpd.conf.default
. After the
- installation has finished you should manually check to see what is
- in new in the .default
file, and if necessary
- update your existing configuration files.
Also, if you already have a file called
- htdocs\index.html
then it will not be overwritten
- (no index.html.default
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 conf
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 htdocs
.
- 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.
There are two ways you can run Apache:
+Apache can be run as a service on Windows NT. There is some + highly experimental support for similar behavior on Windows 9x.
-As a "service" - (available on Windows NT, or a pseudo-service on Windows - 9x). 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.
From a console window. This MUST - be used by any administrator to test before attempting to - run as a service.
You can install Apache as a service automatically during the + installation. If you chose to install for all users, the + installation will create an Apache service for you. If you specify + to install for yourself only, you can manually register Apache as a + service after the installation. You have to be a member of the + Administrators group for the service installation to succeed.
-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 Signalling - Console Apache when Running for how to control Apache from - the command line.
- -If the Apache console window closes immediately (or
- unexpectedly), run the "Command Prompt" from the Start Menu -
- Programs list. Change to the folder to which you installed
- Apache, type the command apache, and read the error message.
- Then change to the logs
folder, and review the
- error.log
file for configuration mistakes.
- If you accepted the defaults when you installed Apache,
- the commands would be:
Apache comes with a utility called the Apache Service Monitor. + With it you can see and manage the state of all installed Apache + services on any machine on your network. To be able to manage an + Apache service with the monitor, you have to first install the + service (either automatically via the installation or manually). +
+ +You can install Apache as a Windows NT service as follows from
+ the command prompt at the Apache bin
subdirectory:
- c:
- cd "\program files\apache group\apache"
- apache
- Wait for Apache to exit, or press Ctrl+C
- cd logs
- more <error.log
+ apache -k install
Complete the steps above before you proceed - to attempt to start Apache as a Windows NT service!
- -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 line with:
+If you need to specify the name of the service you want to + install, use the following command. You have to do this if you + have several different service installations of Apache on your + computer.
- NET START APACHE
- NET STOP APACHE
+ apache -k install -n "MyServiceName"
See Signalling Service Apache when - Running for more information on installing and controlling - Apache services.
+If you need to have specifically named configuration files for + different services, you must use this:
+ +
+ apache -k install -n "MyServiceName" -f "c:\files\my.conf"
+
error.log
file in the
- logs
folder within the Apache server root folder.
- You will not find Apache error details in the Windows
- Event Log.If you use the first command without any special parameters except
+ -k install
, the service will be called Apache2
+ and the configuration will be assumed to be conf\httpd.conf
.
+
After starting Apache running (either in a console window or
- as a service) it will be listening on port 80 (unless you
- changed the Listen
directive in the configuration
- files). To connect to the server and access the default page,
- launch a browser and enter this URL:
Removing an Apache service is easy. Just use:
- http://localhost/
+ apache -k uninstall
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 error_log
file in the logs
- directory. If your host isn't connected to the net, you may
- have to use this URL:
The specific Apache service to be uninstalled can be specified by using:
- http://127.0.0.1/
+ apache -k uninstall -n "MyServiceName"
Once your basic installation is working, you should
- configure it properly by editing the files in the
- conf
directory. Again, if you change the
- configuration of the Windows NT service for Apache, first
- attempt to start it from the command line to assure that the
- service starts with no errors.
Normal starting, restarting and shutting down of an Apache
+ service is usually done via the Apache Service Monitor, by using
+ commands like NET START Apache2
and NET STOP
+ Apache2
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:
Because Apache CANNOT share the same port with - another TCP/IP application, you may need to stop or uninstall - certain services first. These include (but are not limited to) - other web servers, and firewall products such as BlackIce. If - you can only start Apache with these services disabled, - reconfigure either Apache or the other product so that they do - not listen on the same TCP/IP ports.
+
+ apache -n "MyServiceName" -t
+
You can control an Apache service by its command line switches, + too. To start an installed Apache service you'll use this:
- +
+ apache -k start
+
Apache is configured by files in the conf
- 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 Apache
- documentation for all the available directives.
To stop an Apache service via the command line switches, use + this:
-The main differences in Apache for Windows are:
+
+ apache -k stop
+
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:
- -MaxRequestsPerChild
- - 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, MaxRequestsPerChild
- 0
, does not cause the process to ever exit.
httpd.conf
, the new child may not
- start or you may receive unexpected results.ThreadsPerChild
- - 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 ThreadsPerChild
- 50
.
or
-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.
-
+ apache -k shutdown
+
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 \Apache\modules
directory. To
- activate these, or other modules, the new LoadModule
- directive must be used. For example, to active the status
- module, use the following (in addition to the
- status-activating directives in
- access.conf
):
- LoadModule status_module modules/mod_status.so
-
Information on creating loadable - modules is also available.
-You can also restart a running service and force it to reread + its configuration file by using:
-Apache can also load ISAPI Extensions (i.e., - Internet Server Applications), such as those used by - Microsoft's IIS, and other Windows servers. More information is - available. Note that Apache CANNOT load ISAPI - Filters.
-
+ apache -k restart
+
When running CGI scripts, the method Apache uses to find
- the interpreter for the script is configurable using the
- ScriptInterpreterSource
- directive.
By default, all Apache services are registered to run as the
+ system user (the LocalSystem
account). The
+ LocalSystem
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.
+
System
account! If you need Apache to be able to
+ access network resources, create a separate account for Apache as
+ noted below.You may want to create a separate account for running Apache + service(s). Especially, if you have to access network resources + via Apache, this is strongly recommended.
+ +Log on
+ as a service
and Act as part of the operating
+ system
. 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.
Since it is often difficult to manage files with names
- like .htaccess
under windows, you may find it
- useful to change the name of this configuration file using
- the AccessFilename
- directive.
htdocs
and cgi-bin
+ for example).logs
directory.-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".Apache.exe
binary executable.You can install Apache as a Windows NT service as - follows:
+logs
subdirectory, where the
+ user has to have read/write/delete (RWXD) rights.
- apache -k install -n "service name"
-
If you allow the account to log in as a user and as a service, + then you can log in yourself 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.
-To install a service to use a particular configuration, - specify the configuration file when the service is - installed:
+
- apache -k install -n "service name" -f "\my server\conf\my.conf"
-
To remove an Apache service, use
+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:
- apache -k uninstall -n "service name"
+ Could not start the Apache2 service on \\COMPUTER
+ Error 1067; The process terminated unexpectedly.
The default "service name", if one is not specified, is - "Apache".
+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.
-Once a service is installed, you can use the -n
- option, in conjunction with other options, to refer to a
- service's configuration file. For example:
There is some support for Apache on Windows 9x to behave in a + similar manner as a service on Windows NT. It is highly + experimental. It is not of production-class reliability, + and its future is not guaranteed. It can be mostly regarded as + a risky thing to play with - proceed with caution!
-To test a service's configuration file:
+There are some differences between the two kinds of services + you should be aware of:
-
- apache -n "service name" -t
-
Apache will attempt to start and if successful it will run + in the background. If you run the command
+ +
+ apache -n "MyServiceName" -k start
+
via a shortcut on your desktop, for example, then if the + service starts successfully, a console window will flash up but + it immediately disappears. If Apache detects any errors on startup + such as incorrect entries in the httpd.conf configuration file, + the console window will remain visible. This will display an error + message which will be useful in tracking down the cause of the + problem.
Windows 9x does not support NET START
or
+ NET STOP
commands. You must control the Apache
+ service on the command prompt via the -k
switches.
+
Apache and Windows 9x offer no support for running Apache + as a specific user with network privileges. In fact, Windows 9x + offers no security on the local machine, either. This is the + simple reason because of which the Apache Software Foundation + never endorses use of a Windows 9x -based system as a public + Apache server. The primitive support for Windows 9x exists only + to assist the user in developing web content and learning the + Apache server, and perhaps as an intranet server on a secured, + private network.
To start a console Apache using a service's configuration - file:
+
- apache -n "service name"
-
Once you have confirmed that Apache runs correctly as a + console application you can install, control and uninstall the + pseudo-service with the same commands as on Windows NT. You can + also use the Apache Service Monitor to manage Windows 9x + pseudo-services.
-Important Note on service dependencies:
+Running Apache as a service is usually the recommended way to + use it, but it is sometimes easier to work from the command line + (on Windows 9x running Apache from the command line is the + recommended way due to the lack of reliable service support.)
-Prior to Apache release 1.3.13, the dependencies required to - successfully start an installed service were not configured. - After installing a service using earlier versions of Apache, - you must follow these steps:
+To run Apache from the command line as a console application, + use the following command:
- Run regedt32
- Select Window - "HKEY_LOCAL_MACHINE on Local Machine" from the menu
- Double-click to open the SYSTEM, then the CurrentControlSet keys
- Scroll down and click on the Apache servicename
- Select Edit - Add Value... from the menu
- Fill in the Add Value dialog with
- Value Name: DependOnGroup
- Data Type: REG_MULTI_SZ
- and click OK
- Leave the Multi-String Editor dialog empty and click OK
- Select Edit - Add Value... from the menu
- Fill in the Add Value dialog with
- Value Name: DependOnService
- Data Type: REG_MULTI_SZ
- and click OK
- Type the following list (one per line) in the Multi-String Editor dialog
- Tcpip
- Afd
- and click OK
+ apache
If you are using COM or DCOM components from a third party - module, ISAPI, or other add-in scripting technologies such as - ActiveState Perl, you may also need to add the entry Rpcss to - the DependOnService list. To avoid exposing the TCP port 135 - when it is unnecessary, Apache does not create that entry upon - installation. Follow the directions above to find or create the - DependOnService value, double click that value if it already - exists, and add the Rpcss entry to the list.
+Apache will execute, and will remain running until it is stopped + by pressing Control-C.
-You can also run Apache via the shortcut Start Apache in Console
+ placed to Start Menu --> Programs --> Apache HTTP Server
+ 2.0.xx --> Control Apache Server
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.
You can tell a running Apache to stop by opening another console + window and entering:
-The Start menu icons and the Windows Service manager can provide - a simple interface for administering Apache. But in some cases - it is easier to work from the command line.
+
+ apache -k shutdown
+
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 in two ways:
+This should be preferred over pressing Control-C because this + lets Apache end any current operations and clean up gracefully.
--f
specifies a path to a particular
- configuration fileYou 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, use:
- apache -f "c:\my server\conf\my.conf"
- apache -f test\test.conf
+ apache -k restart
-n
specifies the configuration file of
- an installed Apache service (Apache 1.3.7 and later)kill -TERM
+ pid
and kill -USR1 pid
. The
+ command line option used, -k
, was chosen as a reminder
+ of the kill
command used on Unix.If the Apache console window closes immediately or unexpectedly
+ after startup, open the Command Prompt from the Start Menu -->
+ Programs. Change to the folder to which you installed Apache, type
+ the command apache
, and read the error message. Then
+ change to the logs folder, and review the error.log
+ file for configuration mistakes. If you accepted the defaults when
+ you installed Apache, the commands would be:
- apache -n "service name"
+ c:
+ cd "\Program Files\Apache Group\Apache2\bin"
+ apache
In these cases, the proper ServerRoot
should be set in the configuration file.
Then wait for Apache to stop, or press Control-C. Then enter the + following:
-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:
+ cd ..\logs
+ more < error.log
+
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:
ServerRoot
directive via a
- -C
switch.-f
specifies an absolute or relative path to
+ a particular configuration file:
-d
switch on the command line.
+ apache -f "c:\my server files\anotherconfig.conf"
+
or
-
+ apache -f files\anotherconfig.conf
+
-n
specifies the installed Apache service
+ whose configuration file is to be used:
The server root compiled into the server is usually
- "/apache
". invoking apache with the -V
switch
- will display this value labeled as HTTPD_ROOT
.
+ apache -n "MyServiceName"
+
When invoked from the start menu, Apache is usually passed - no arguments, so using the registry entry is the preferred - technique for console Apache.
+In both of these cases, the proper
+ ServerRoot
should be set in
+ the configuration file.
During a binary installation, a version-specific registry - key is created in the Windows registry:
+If you don't specify a configuration file with -f
+ or -n
, Apache will use the file name compiled into the
+ server, such as conf\httpd.conf
. This built-in path
+ is relative to the installation directory. You can verify the compiled
+ file name from a value labelled as SERVER_CONFIG_FILE
when
+ invoking Apache with the -V
switch, like this:
- HKEY_LOCAL_MACHINE\Software\Apache Group\Apache\1.3.7
-
- HKEY_LOCAL_MACHINE\Software\Apache Group\Apache\2.0a3
+ apache -V
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 - configuration files.
- -The value of this key is the ServerRoot
directory, containing the conf
- directory. When Apache starts it will read the httpd.conf
- file from this directory. If this file contains a
- ServerRoot
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
- ServerRoot
directory
- in the httpd.conf
file to the new location.
To run Apache from the command line as a console - application, use the following command:
+Apache will then try to determine its
+ ServerRoot
by trying the following, in this order:
- apache
-
ServerRoot
directive
+ via the -C
command line switch.Apache will execute, and will remain running until it is - stopped by pressing control-C.
+-d
switch on the command line.
+ /apache
by default, you can verify it by using
+ apache -V
and looking for a value labelled as
+ HTTPD_ROOT
.On Windows NT, multiple instances of Apache can be run as - services. Signal an Apache service to start, restart, or - shutdown as follows:
+During the installation, a version-specific registry key is
+ created in the Windows registry. The location of this key depends
+ on the type of the installation. If you chose to install Apache
+ for all users, the key is located under the
+ HKEY_LOCAL_MACHINE
hive, like this (the version
+ numbers will of course vary between different versions of Apache:
+
- apache -n "service name" -k start
- apache -n "service name" -k restart
- apache -n "service name" -k shutdown
+ HKEY_LOCAL_MACHINE\SOFTWARE\Apache Group\Apache\2.0.43
In addition, when running on Windows NT, you can use the
- native NET
command to start and stop Apache services
- as follows:
Correspondingly, if you chose to install Apache for the current
+ user only, the key is located under the HKEY_CURRENT_USER
+ hive, the contents of which are dependent of the user currently
+ logged on:
- NET START "service name"
- NET STOP "service name"
+ HKEY_CURRENT_USER\SOFTWARE\Apache Group\Apache\2.0.43
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 in the same + directory as another version.
+ +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.
+ +The value of this key is the
+ ServerRoot
directory which
+ contains the conf
subdirectory. When Apache starts it
+ reads the httpd.conf
file from that directory. If
+ this file contains a ServerRoot
+ 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
+ ServerRoot
directive in the
+ httpd.conf
file to reflect the new location.
On Windows 9x, Apache runs as a console application. You can - tell a running Apache to stop by opening another console window - and typing:
+After starting Apache (either in a console window or as a
+ service) it will be listening on port 80 (unless you changed the
+ Listen
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:
- apache -k shutdown
+ http://localhost/
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
+Apache should respond with a welcome page and a link to the
+ Apache manual. If nothing happens or you get an error, look in the
+ error.log
file in the logs
subdirectory.
+ If your host is not connected to the net, you may have to use this
+ URL:
- apache -k restart
+ http://127.0.0.1/
kill -TERM
- pid
and kill -USR1 pid
.
- The command line option used, -k
, was chosen as a
- reminder of the "kill
" command used on Unix.Once your basic installation is working, you should configure it
+ properly by editing the files in the conf
subdirectory.
+ Again, if you change the configuration of the Windows NT service
+ for Apache, first attempt to start it from the command line to
+ assure that the service starts with no errors.
Because Apache cannot share the same port with + another TCP/IP application, you may need to stop or uninstall + certain other services before running Apache. These conflicting + services include other WWW servers and some firewall implementations. +