]> granicus.if.org Git - apache/blob - docs/manual/invoking.xml
Update the copyright year in all .c, .h and .xml files
[apache] / docs / manual / invoking.xml
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$ -->
5
6 <!--
7  Copyright 2002-2006 The Apache Software Foundation or its licensors, as
8  applicable.
9
10  Licensed under the Apache License, Version 2.0 (the "License");
11  you may not use this file except in compliance with the License.
12  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
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.
21 -->
22
23 <manualpage metafile="invoking.xml.meta">
24
25   <title>Starting Apache</title>
26
27 <summary>
28     <p>On Windows, Apache is normally run as a service on Windows
29     NT, 2000 and XP, or as a console application on Windows 9x and
30     ME. For details, see <a
31     href="platform/windows.html#winsvc">Running Apache as a Service</a>
32     and <a href="platform/windows.html#wincons">Running Apache as a
33     Console Application</a>.</p>
34
35     <p>On Unix, the <program>httpd</program> program
36     is run as a daemon that executes continuously in the
37     background to handle requests.  This document describes how
38     to invoke <program>httpd</program>.</p>
39 </summary>
40
41 <seealso><a href="stopping.html">Stopping and Restarting</a></seealso>
42 <seealso><program>httpd</program></seealso>
43 <seealso><program>apachectl</program></seealso>
44
45 <section id="startup"><title>How Apache Starts</title>
46
47     <p>If the <directive module="mpm_common">Listen</directive>
48     specified in the configuration file is default of 80 (or any other
49     port below 1024), then it is necessary to have root privileges in
50     order to start apache, so that it can bind to this privileged
51     port. Once the server has started and performed a few preliminary
52     activities such as opening its log files, it will launch several
53     <em>child</em> processes which do the work of listening for and
54     answering requests from clients. The main <code>httpd</code>
55     process continues to run as the root user, but the child processes
56     run as a less privileged user. This is controlled by the selected
57     <a href="mpm.html">Multi-Processing Module</a>.</p>
58
59     <p>The recommended method of invoking the <program>httpd</program>
60     executable is to use the <program>apachectl</program> control script. This
61     script sets certain environment variables that are necessary for
62     <program>httpd</program> to function correctly under some operating
63     systems, and then invokes the <program>httpd</program> binary.
64     <program>apachectl</program> will pass through any command line
65     arguments, so any <program>httpd</program> options may also be used with
66     <program>apachectl</program>.  You may also directly edit the
67     <program>apachectl</program> script by changing the <code>HTTPD</code>
68     variable near the top to specify the correct location of the
69     <program>httpd</program> binary and any command-line arguments that you
70     wish to be <em>always</em> present.</p>
71
72     <p>The first thing that <code>httpd</code> does when it is
73     invoked is to locate and read the <a
74     href="configuring.html">configuration file</a>
75     <code>httpd.conf</code>. The location of this file is set at
76     compile-time, but it is possible to specify its location at run
77     time using the <code>-f</code> command-line option as in</p>
78
79 <example>/usr/local/apache2/bin/apachectl -f
80       /usr/local/apache2/conf/httpd.conf</example>
81
82     <p>If all goes well during startup, the server will detach from
83     the terminal and the command prompt will return almost
84     immediately. This indicates that the server is up and running.
85     You can then use your browser to connect to the server and view
86     the test page in the <directive
87     module="core">DocumentRoot</directive> directory
88     and the local copy of the documentation linked from that
89     page.</p>
90 </section>
91
92 <section id="errors"><title>Errors During Start-up</title>
93
94     <p>If Apache suffers a fatal problem during startup, it will
95     write a message describing the problem either to the console or
96     to the <directive module="core">ErrorLog</directive> before
97     exiting. One of the most common error messages is "<code>Unable
98     to bind to Port ...</code>". This message is usually caused by
99     either:</p>
100
101     <ul>
102       <li>Trying to start the server on a privileged port when not
103       logged in as the root user; or</li>
104
105       <li>Trying to start the server when there is another instance
106       of Apache or some other web server already bound to the same
107       Port.</li>
108     </ul>
109
110     <p>For further trouble-shooting instructions, consult the
111     Apache <a href="faq/">FAQ</a>.</p>
112 </section>
113
114 <section id="boot"><title>Starting at Boot-Time</title>
115
116     <p>If you want your server to continue running after a system
117     reboot, you should add a call to <program>apachectl</program> to your
118     system startup files (typically <code>rc.local</code> or a file in
119     an <code>rc.N</code> directory). This will start Apache as
120     root. Before doing this ensure that your server is properly
121     configured for security and access restrictions.</p>
122
123     <p>The <program>apachectl</program> script is designed to act like a
124     standard SysV init script; it can take the arguments
125     <code>start</code>, <code>restart</code>, and <code>stop</code>
126     and translate them into the appropriate signals to
127     <program>httpd</program>.  So you can often simply link
128     <program>apachectl</program> into the appropriate init directory. But be
129     sure to check the exact requirements of your system.</p>
130 </section>
131
132 <section id="info"><title>Additional Information</title>
133
134     <p>Additional information about the command-line options of <program>
135     httpd</program> and <program>apachectl</program> as well as other support
136     programs included with the server is available on the
137     <a href="programs/">Server and Supporting Programs</a> page.
138     There is also documentation on all the <a
139     href="mod/">modules</a> included with the Apache distribution
140     and the <a href="mod/directives.html">directives</a> that they
141     provide.</p>
142 </section>
143
144 </manualpage>