win_service.html revision 7cebe0ba33ae904951119a6a0a9d0ea2773f18c3
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<TITLE>Running Apache for Windows as a Service</TITLE>
c58f1213e628a545081c70e26c6b67a841cff880vboxsync<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync BGCOLOR="#FFFFFF"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync TEXT="#000000"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync LINK="#0000FF"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync VLINK="#000080"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync ALINK="#FF0000"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<!--#include virtual="header.html" -->
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<H1 ALIGN="CENTER">Running Apache for Windows as a Service</H1>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<P>Apache can be run as a service on Windows NT/2000. (There is also some
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync HIGHLY EXPERIMENTAL support for similar behavior on
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync <a href="#win95svc">Windows 95/98</a>, introduced with Apache 1.3.13).</P>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<P>Installing Apache as a service should only be done once you can
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync successfully run it in a console window. See
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync <A HREF="windows.html">Using Apache with Microsoft Windows</A>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync before you attempt to install or run Apache as a service. Changes to the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync httpd.conf file should always be followed by starting Apache as a console
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync window. If this succeeds, the service should succeed.</P>
8683cfdc9273dd77e1c4e89886a7052de103591avboxsync<P><STRONG>NOTE: Prior to version 1.3.13, the configuration was <EM>not
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync tested</EM> prior to performing the installation</STRONG>, and a lack of
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync service dependencies often caused the console window to succeed, but the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync service would still fail. See <A HREF="#service">below</A> if you are
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync having problems running a version of Apache prior to 1.3.13 to resolve the
468c2bcb36eb9a032f5dd0fcb34db10bd58e9996vboxsync issue. If you have this problem with version 1.3.13 or greater, first try
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync uninstalling (-u) and re-installing (-i) the Apache service.</P>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<P>To start Apache as a service, you first need to install it as a
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync service. Multiple Apache services can be installed, each with a
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync different name and configuration. To install the default Apache
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync service named "Apache", run the "Install Apache as Service (NT only)"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync option from the Start menu. Once this is done you can start the "Apache"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync service by opening the Services window (in the Control Panel), selecting
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync Apache, then clicking on Start. Apache will now be running, hidden in the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync background. You can later stop Apache by clicking on Stop. As an
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync alternative to using the Services window, you can start and stop the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync "Apache" service from the command line with</P>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync NET START APACHE
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync NET STOP APACHE
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<P>See <A HREF="#signal">Controlling Apache as a Service</A>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync for more information on installing and controlling Apache services.</P>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<P><STRONG>Apache, unlike many other Windows NT/2000 services, logs any
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync errors to it's own error.log file in the logs folder within the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync Apache server root folder. You will <EM>not</EM> find Apache error
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<P>After starting Apache as a service (or if you have trouble starting it)
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync you can test it using the same <A HREF="windows.html#cmdline">procedure</a>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync as for running in a console window. Remember to use the command:</P>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync apache -n "service name"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<P>to assure you are using the service's configuration.</P>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<H2><A NAME="service">Running Apache for Windows as a Service</A></H2>
65697a26b524640b83828b715160c798c43a0424vboxsync<P><STRONG>Note: The -n option to specify a service name is only available
65697a26b524640b83828b715160c798c43a0424vboxsync with Apache 1.3.7 and later.</STRONG> Earlier versions of Apache only
65697a26b524640b83828b715160c798c43a0424vboxsync support the default service name 'Apache'.</P>
65697a26b524640b83828b715160c798c43a0424vboxsync<P>You can install Apache as a Windows NT service as follows:</P>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync apache -i -n "service name"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<P>To install a service to use a particular configuration, specify the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync configuration file when the service is installed:</P>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync apache -i -n "service name" -f "\my server\conf\my.conf"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync apache -u -n "service name"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<P>The default "service name", if one is not specified, is "Apache".</P>
26947320577c481b4afefdb0afbb855181e5b2e8vboxsync<P>Once a service is installed, you can use the <SAMP>-n</SAMP> option, in
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync conjunction with other options, to refer to a service's configuration file.
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync For example:</P>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync apache -n "service name" -t
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<P>To start a console Apache using a service's configuration file:</P>
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync apache -n "service name"
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync<H2><A NAME="depends">Important Note on service dependencies:</A></H2>
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync<P>Prior to Apache release 1.3.13, the dependencies required to
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync successfully start an installed service were not configured.
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync After installing a service using earlier versions of Apache,
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync you must follow these steps:
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync Run regedt32
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync Select <U>W</U>indow - "HKEY_LOCAL_MACHINE on Local Machine" from the menu
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync Double-click to open the SYSTEM, then the CurrentControlSet keys
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync Scroll down and click on the Apache servicename
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync Select <U>E</U>dit - Add <U>V</U>alue... from the menu
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync Fill in the Add Value dialog with
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync and click OK
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync Leave the Multi-String Editor dialog empty and click OK
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync Select <U>E</U>dit - Add <U>V</U>alue... from the menu
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync Fill in the Add Value dialog with
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync and click OK
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync Type the following list (one per line) in the Multi-String Editor dialog
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync and click OK
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync<P>If you are using COM or DCOM components from a third party module, ISAPI,
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync or other add-in scripting technologies such as ActiveState Perl, you may
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync also need to add the entry Rpcss to the DependOnService list. To avoid
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync exposing the TCP port 135 when it is unnecessary, Apache does not create
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync that entry upon installation. Follow the directions above to find or
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync create the DependOnService value, double click that value if it already
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync exists, and add the Rpcss entry to the list.</P>
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync<H2>User Account for Apache Service to Run As (NT/2000)</H2>
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync<P>When Apache is first installed as a service (e.g. with the -i option)
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync it will run as user "System" (the LocalSystem account). There should
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync be few issues if all resources for the web server reside on the local
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync system, but it has broad security privilages to affect the local machine!</P>
httpd.conf file, then the console window will remain visible. This will
<!--#include virtual="footer.html" -->