1 <?xml version='1.0' encoding='UTF-8' ?>
2 <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="./style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <manualpage metafile="invoking.xml.meta">
25 <title>Starting Apache</title>
28 <p>On Windows, Apache is normally run as a service on Windows
29 NT, 2000 and XP. For details, see <a
30 href="platform/windows.html#winsvc">Running Apache as a Service</a>.
33 <p>On Unix, the <program>httpd</program> program
34 is run as a daemon that executes continuously in the
35 background to handle requests. This document describes how
36 to invoke <program>httpd</program>.</p>
39 <seealso><a href="stopping.html">Stopping and Restarting</a></seealso>
40 <seealso><program>httpd</program></seealso>
41 <seealso><program>apachectl</program></seealso>
43 <section id="startup"><title>How Apache Starts</title>
45 <p>If the <directive module="mpm_common">Listen</directive>
46 specified in the configuration file is default of 80 (or any other
47 port below 1024), then it is necessary to have root privileges in
48 order to start apache, so that it can bind to this privileged
49 port. Once the server has started and performed a few preliminary
50 activities such as opening its log files, it will launch several
51 <em>child</em> processes which do the work of listening for and
52 answering requests from clients. The main <code>httpd</code>
53 process continues to run as the root user, but the child processes
54 run as a less privileged user. This is controlled by the selected
55 <a href="mpm.html">Multi-Processing Module</a>.</p>
57 <p>The recommended method of invoking the <program>httpd</program>
58 executable is to use the <program>apachectl</program> control script. This
59 script sets certain environment variables that are necessary for
60 <program>httpd</program> to function correctly under some operating
61 systems, and then invokes the <program>httpd</program> binary.
62 <program>apachectl</program> will pass through any command line
63 arguments, so any <program>httpd</program> options may also be used with
64 <program>apachectl</program>. You may also directly edit the
65 <program>apachectl</program> script by changing the <code>HTTPD</code>
66 variable near the top to specify the correct location of the
67 <program>httpd</program> binary and any command-line arguments that you
68 wish to be <em>always</em> present.</p>
70 <p>The first thing that <program>httpd</program> does when it is
71 invoked is to locate and read the <a
72 href="configuring.html">configuration file</a>
73 <code>httpd.conf</code>. The location of this file is set at
74 compile-time, but it is possible to specify its location at run
75 time using the <code>-f</code> command-line option as in</p>
77 <example>/usr/local/apache2/bin/apachectl -f
78 /usr/local/apache2/conf/httpd.conf</example>
80 <p>If all goes well during startup, the server will detach from
81 the terminal and the command prompt will return almost
82 immediately. This indicates that the server is up and running.
83 You can then use your browser to connect to the server and view
84 the test page in the <directive
85 module="core">DocumentRoot</directive> directory.</p>
88 <section id="errors"><title>Errors During Start-up</title>
90 <p>If Apache suffers a fatal problem during startup, it will
91 write a message describing the problem either to the console or
92 to the <directive module="core">ErrorLog</directive> before
93 exiting. One of the most common error messages is "<code>Unable
94 to bind to Port ...</code>". This message is usually caused by
98 <li>Trying to start the server on a privileged port when not
99 logged in as the root user; or</li>
101 <li>Trying to start the server when there is another instance
102 of Apache or some other web server already bound to the same
106 <p>For further trouble-shooting instructions, consult the
107 Apache <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a>.</p>
110 <section id="boot"><title>Starting at Boot-Time</title>
112 <p>If you want your server to continue running after a system
113 reboot, you should add a call to <program>apachectl</program> to your
114 system startup files (typically <code>rc.local</code> or a file in
115 an <code>rc.N</code> directory). This will start Apache as
116 root. Before doing this ensure that your server is properly
117 configured for security and access restrictions.</p>
119 <p>The <program>apachectl</program> script is designed to act like a
120 standard SysV init script; it can take the arguments
121 <code>start</code>, <code>restart</code>, and <code>stop</code>
122 and translate them into the appropriate signals to
123 <program>httpd</program>. So you can often simply link
124 <program>apachectl</program> into the appropriate init directory. But be
125 sure to check the exact requirements of your system.</p>
128 <section id="info"><title>Additional Information</title>
130 <p>Additional information about the command-line options of <program>
131 httpd</program> and <program>apachectl</program> as well as other support
132 programs included with the server is available on the
133 <a href="programs/">Server and Supporting Programs</a> page.
134 There is also documentation on all the <a
135 href="mod/">modules</a> included with the Apache distribution
136 and the <a href="mod/directives.html">directives</a> that they