home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / apache_2.2.8-win32-x86-no_ssl.msi / Data1.cab / windows.html.en < prev    next >
Extensible Markup Language  |  2007-12-30  |  37KB  |  755 lines

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