invoking.html.en revision 39439c95488c2e66ea8b35c47f75e9ec2508d8fb
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><!--
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering This file is generated from xml source: DO NOT EDIT
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering --><title>Starting Apache - Apache HTTP Server</title><link href="/style/manual.css" type="text/css" rel="stylesheet"></head><body><blockquote><div align="center"><img src="/images/sub.gif" alt="[APACHE DOCUMENTATION]"><h3>Apache HTTP Server Version 2.0</h3></div><h1 align="center">Starting Apache</h1>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <p>On Windows, Apache is normally run as a service on Windows
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering NT, or as a console application on Windows 95. For details, see
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <a href="platform/windows.html#run">running Apache for
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering Windows</a>.</p>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <p>On Unix, the <a href="programs/httpd.html">httpd</a> program
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering is run as a daemon that executes continuously in the
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering background to handle requests. This document describes how
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering to invoke <code>httpd</code>.</p>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering<ul><li><a href="#startup">How Apache Starts</a></li><li><a href="#errors">Errors During Start-up</a></li><li><a href="#boot">Starting at Boot-Time</a></li><li><a href="#info">Additional Information</a></li></ul><hr><h2><a name="startup">How Apache Starts</a></h2>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <p>If the <a href="/mod/mpm_common.html#listen" class="directive"><code class="directive">Listen</code></a>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering specified in the configuration file is default of 80 (or any other
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering port below 1024), then it is necessary to have root privileges in
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering order to start apache, so that it can bind to this privileged
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering port. Once the server has started and performed a few preliminary
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering activities such as opening its log files, it will launch several
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <em>child</em> processes which do the work of listening for and
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering answering requests from clients. The main <code>httpd</code>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering process continues to run as the root user, but the child processes
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering run as a less privileged user. This is controlled by the selected
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <a href="mpm.html">Multi-Processing Module</a>.</p>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <p>The first thing that <code>httpd</code> does when it is
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering invoked is to locate and read the <a href="configuring.html">configuration file</a>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <code>httpd.conf</code>. The location of this file is set at
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering compile-time, but it is possible to specify its location at run
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering time using the <code>-f</code> command-line option as in</p>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>/usr/local/apache/bin/httpd -f
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering /usr/local/apache/conf/httpd.conf</code></td></tr></table></blockquote>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <p>As an alternative to invoking the <code>httpd</code> binary
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering directly, a shell script called <a href="programs/apachectl.html">apachectl</a> is provided which
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering can be used to control the daemon process with simple commands
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering such as <code>apachectl start</code> and <code>apachectl
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering stop</code>.</p>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <p>If all goes well during startup, the server will detach from
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering the terminal and the command prompt will return almost
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering immediately. This indicates that the server is up and running.
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering You can then use your browser to connect to the server and view
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering the test page in the <a href="/mod/core.html#documentroot" class="directive"><code class="directive">DocumentRoot</code></a> directory
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering and the local copy of the documentation linked from that
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering page.</p>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering<h2><a name="errors">Errors During Start-up</a></h2>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <p>If Apache suffers a fatal problem during startup, it will
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering write a message describing the problem either to the console or
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering to the <a href="/mod/core.html#errorlog" class="directive"><code class="directive">ErrorLog</code></a> before
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering exiting. One of the most common error messages is "<code>Unable
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering to bind to Port ...</code>". This message is usually caused by
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering either:</p>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <ul>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <li>Trying to start the server on a privileged port when not
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering logged in as the root user; or</li>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <li>Trying to start the server when there is another instance
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering of Apache or some other web server already bound to the same
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering Port.</li>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering </ul>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <p>For further trouble-shooting instructions, consult the
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering Apache <a href="faq/">FAQ</a>.</p>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering<h2><a name="boot">Starting at Boot-Time</a></h2>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <p>If you want your server to continue running after a system
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering reboot, you should add a call to <code>httpd</code> or
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <code>apachectl</code> to your system startup files (typically
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <code>rc.local</code> or a file in an <code>rc.N</code>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering directory). This will start Apache as root. Before doing this
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering ensure that your server is properly configured for security and
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering access restrictions. The <code>apachectl</code> script is
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering designed so that it can often be linked directly as an init
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering script, but be sure to check the exact requirements of your
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering system.</p>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering<h2><a name="info">Additional Information</a></h2>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <p>Additional information about the command-line options of <a href="programs/httpd.html">httpd</a> and <a href="programs/apachectl.html">apachectl</a> as well as other
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering support programs included with the server is available on the
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering <a href="programs/">Server and Supporting Programs</a> page.
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering There is also documentation on all the <a href="mod/">modules</a> included with the Apache distribution
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering and the <a href="mod/directives.html">directives</a> that they
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering provide.</p>
e9d21f240704f87c6bb5f7fca1c5e6d0f31c84cdLennart Poettering<hr></blockquote><h3 align="center">Apache HTTP Server Version 2.0</h3><a href="./"><img src="/images/index.gif" alt="Index"></a><a href="./"><img src="/images/home.gif" alt="Home"></a></body></html>