]> granicus.if.org Git - apache/blob - docs/manual/bind.html.en
Update the "bind" docs, remove the stuff from "server-wide.html" that
[apache] / docs / manual / bind.html.en
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML><HEAD>
3 <TITLE>Setting which addresses and ports Apache uses</TITLE>
4 </HEAD>
5
6 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
7 <BODY
8  BGCOLOR="#FFFFFF"
9  TEXT="#000000"
10  LINK="#0000FF"
11  VLINK="#000080"
12  ALINK="#FF0000"
13 >
14 <!--#include virtual="header.html" -->
15 <H1 ALIGN="CENTER">Setting which addresses and ports Apache uses</H1>
16
17 <p>When Apache starts, it connects to some port and address on the
18 local machine and waits for incoming requests. By default, it
19 listens to all addresses on the machine, and to the port
20 as specified by the <code>Port</code> directive in the server configuration.
21 However, it can be told to listen to more the one port, or to listen
22 to only selected addresses, or a combination. This is often combined
23 with the Virtual Host feature which determines how Apache
24 responds to different IP addresses, hostnames and ports.</p>
25
26 <p>The <code>Listen</code> directive tells the server to accept
27 incoming requests only on the specified port or address-and-port
28 combinations. If only a port number is specified in the
29 <code>Listen</code> directive, the server listens to the given port on
30 all interfaces, instead of the port given by the <code>Port</code>
31 directive. If an IP address is given as well as a port, the server
32 will listen on the given port and interface.  Multiple Listen
33 directives may be used to specify a number of addresses and ports to
34 listen to. The server will respond to requests from any of the listed
35 addresses and ports.</P>
36
37 <p>For example, to make the server accept connections on both port
38 80 and port 8000, use:
39 <PRE>
40    Listen 80
41    Listen 8000
42 </PRE>
43
44 To make the server accept connections on two specified
45 interfaces and port numbers, use
46 <PRE>
47    Listen 192.170.2.1:80
48    Listen 192.170.2.5:8000
49 </PRE>
50
51 <H2>How this works with Virtual Hosts</H2>
52
53 <p>Listen does not implement Virtual Hosts.  It only tells the
54 main server what addresses and ports to listen to.  If no
55 &lt;VirtualHost&gt; directives are used, the server will behave the
56 same for all accepted requests. However, &lt;VirtualHost&gt; can be
57 used to specify a different behavior for one or more of the addresses
58 and ports. To implement a VirtualHost, the server must first be told
59 to listen to the address and port to be used. Then a
60 &lt;VirtualHost&gt; section should be created for a specified address
61 and port to set the behavior of this virtual host. Note that if the
62 &lt;VirtualHost&gt; is set for an address and port that the server is
63 not listening to, it cannot be accessed.
64
65 <H2>See also</H2>
66
67 See also the documentation on
68 <a href="mod/mpm_common.html#listen">Listen directive</a>,
69 <A HREF="vhosts/index.html">Virtual Hosts</A>,
70 <A HREF="mod/core.html#port">Port directive</A>,
71 <A HREF="dns-caveats.html">DNS Issues</A>
72 and
73 <A HREF="mod/core.html#virtualhost">&lt;VirtualHost&gt; section</A>.
74
75 <!--#include virtual="footer.html" -->
76 </BODY>
77 </HTML>
78