]> granicus.if.org Git - apache/blob - docs/manual/install.html
Part 2 of the semi-regular HTML normalisation. Now on to
[apache] / docs / manual / install.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>Compiling and Installing Apache</TITLE>
5 </HEAD>
6
7 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
8 <BODY
9  BGCOLOR="#FFFFFF"
10  TEXT="#000000"
11  LINK="#0000FF"
12  VLINK="#000080"
13  ALINK="#FF0000"
14 >
15 <!--#include virtual="header.html" -->
16
17 <H1 ALIGN="CENTER">Compiling and Installing Apache 1.3</H1>
18
19 UnixWare users will want to consult <A HREF="unixware.html">build notes</A>
20 for various UnixWare versions before compiling.
21
22 <H2>Downloading Apache</H2>
23
24 Information on the latest version of Apache can be found on the Apache
25 web server at <A
26 HREF="http://www.apache.org/">http://www.apache.org/</A>.  This will
27 list the current release, any more recent beta-test release, together
28 with details of mirror web and anonymous ftp sites.
29
30 <P>
31
32 If you downloaded a binary distribution, skip to <A
33 HREF="#install">Installing Apache</A>. Otherwise read the next section
34 for how to compile the server.
35
36 <H2>Compiling Apache</H2>
37
38 Compiling Apache consists of three steps: Firstly select which Apache
39 <STRONG>modules</STRONG> you want to include into the server. Secondly create a
40 configuration for your operating system. Thirdly compile the
41 executable.
42 <P>
43
44 All configuration of Apache is performed in the <CODE>src</CODE>
45 directory of the Apache distribution. Change into this directory.
46
47 <OL>
48  <LI>
49   Select modules to compile into Apache in the
50   <CODE>Configuration</CODE> file. Uncomment lines corresponding to
51   those optional modules you wish to include (among the AddModule lines
52   at the bottom of the file), or add new lines corresponding to
53   additional modules you have downloaded or written. (See <A
54   HREF="misc/API.html">API.html</A> for preliminary docs on how to
55   write Apache modules).  Advanced users can comment out some of the
56   default modules if they are sure they will not need them (be careful
57   though, since many of the default modules are vital for the correct
58   operation and security of the server).
59   <P>
60
61   You should also read the instructions in the <CODE>Configuration</CODE>
62   file to see if you need to set any of the <CODE>Rule</CODE> lines.
63
64
65  <LI>
66   Configure Apache for your operating system. Normally you can just
67   type run the <CODE>Configure</CODE> script as given below. However
68   if this fails or you have any special requirements (e.g. to include
69   an additional library required by an optional module) you might need
70   to edit one or more of the following options in the
71   <CODE>Configuration</CODE> file:
72     <CODE>EXTRA_CFLAGS, LIBS, LDFLAGS, INCLUDES</CODE>.
73   <P>
74
75   Run the <CODE>Configure</CODE> script:
76   <BLOCKQUOTE>
77    <PRE>
78     % Configure
79     Using 'Configuration' as config file
80      + configured for &lt;whatever&gt; platform
81      + setting C compiler to &lt;whatever&gt; *
82      + setting C compiler optimization-level to &lt;whatever&gt; *
83      + Adding selected modules
84      + doing sanity check on compiler and options
85     Creating Makefile in support
86     Creating Makefile in main
87     Creating Makefile in os/unix
88     Creating Makefile in modules/standard
89    </PRE>
90   </BLOCKQUOTE>
91
92   (*: Depending on Configuration and your system, Configure
93   make not print these lines. That's OK).<P>
94
95   This generates a Makefile for use in stage 3. It also creates a
96   Makefile in the support directory, for compilation of the optional
97   support programs.
98   <P>
99
100   (If you want to maintain multiple configurations, you can give a
101   option to <CODE>Configure</CODE> to tell it to read an alternative
102   Configuration file, such as <CODE>Configure -file
103   Configuration.ai</CODE>).
104   <P>
105
106  <LI>
107   Type <CODE>make</CODE>.
108 </OL>
109
110 The modules we place in the Apache distribution are the ones we have
111 tested and are used regularly by various members of the Apache
112 development group.  Additional modules contributed by members or third
113 parties with specific needs or functions are available at
114 &lt;<A HREF="http://www.apache.org/dist/contrib/modules/"
115     >http://www.apache.org/dist/contrib/modules/</A>&gt;.
116 There are instructions on that page for linking these modules into the
117 core Apache code.
118
119 <H2><A NAME="install">Installing Apache</A></H2>
120
121 You will have a binary file called <CODE>httpd</CODE> in the
122 <CODE>src</CODE> directory.  A binary distribution of Apache will
123 supply this file.  <P>
124
125 The next step is to install the program and configure it. Apache is
126 designed to be configured and run from the same set of directories
127 where it is compiled. If you want to run it from somewhere else, make
128 a directory and copy the <CODE>conf</CODE>, <CODE>logs</CODE> and
129 <CODE>icons</CODE> directories into it.  In either case you should
130 read the <A HREF="misc/security_tips.html#serverroot">security tips</A>
131 describing how to set the permissions on the server root directory.<P>
132
133 The next step is to edit the configuration files for the server. This
134 consists of setting up various <STRONG>directives</STRONG> in up to three
135 central configuration files. By default, these files are located in
136 the <CODE>conf</CODE> directory and are called <CODE>srm.conf</CODE>,
137 <CODE>access.conf</CODE> and <CODE>httpd.conf</CODE>.  To help you get
138 started there are same files in the <CODE>conf</CODE> directory of the
139 distribution, called <CODE>srm.conf-dist</CODE>,
140 <CODE>access.conf-dist</CODE> and <CODE>httpd.conf-dist</CODE>. Copy
141 or rename these files to the names without the <CODE>-dist</CODE>.
142 Then edit each of the files. Read the comments in each file carefully.
143 Failure to setup these files correctly could lead to your server not
144 working or being insecure. You should also have an additional file in
145 the <CODE>conf</CODE> directory called <CODE>mime.types</CODE>. This
146 file usually does not need editing.
147
148 <P>
149
150 First edit <CODE>httpd.conf</CODE>.  This sets up general attributes
151 about the server: the port number, the user it runs as, etc.  Next
152 edit the <CODE>srm.conf</CODE> file; this sets up the root of the
153 document tree, special functions like server-parsed HTML or internal
154 imagemap parsing, etc.  Finally, edit the <CODE>access.conf</CODE>
155 file to at least set the base cases of access.
156
157 <P>
158
159 In addition to these three files, the server behavior can be configured
160 on a directory-by-directory basis by using <CODE>.htaccess</CODE>
161 files in directories accessed by the server.
162
163 <H3>Set your system time properly!</H3>
164
165 Proper operation of a public web server requires accurate time
166 keeping, since elements of the HTTP protocol are expressed as the time
167 of day.  So, it's time to investigate setting up NTP or some other
168 time synchronization system on your Unix box, or whatever the
169 equivalent on NT would be.
170
171 <H3>Starting and Stopping the Server</H3>
172
173 To start the server, simply run <CODE>httpd</CODE>. This will look for
174 <CODE>httpd.conf</CODE> in the location compiled into the code (by
175 default <CODE>/usr/local/apache/conf/httpd.conf</CODE>). If
176 this file is somewhere else, you can give the real
177 location with the -f argument. For example:
178
179 <PRE>
180     /usr/local/apache/httpd -f /usr/local/apache/conf/httpd.conf
181 </PRE>
182
183 If all goes well this will return to the command prompt almost
184 immediately.  This indicates that the server is now up and running. If
185 anything goes wrong during the initialization of the server you will
186 see an error message on the screen.
187
188 If the server started ok, you can now use your browser to
189 connect to the server and read the documentation. If you are running
190 the browser on the same machine as the server and using the default
191 port of 80, a suitable URL to enter into your browser is
192
193 <PRE>
194     http://localhost/
195 </PRE>
196
197 <P>
198
199 Note that when the server starts it will create a number of
200 <EM>child</EM> processes to handle the requests. If you started Apache
201 as the root user, the parent process will continue to run as root
202 while the children will change to the user as given in the httpd.conf
203 file.
204
205 <P>
206
207 If when you run <CODE>httpd</CODE> it complained about being unable to
208 "bind" to an address, then either some other process is already using
209 the port you have configured Apache to use, or you are running httpd
210 as a normal user but trying to use port below 1024 (such as the
211 default port 80).
212
213 <P>
214
215 If the server is not running, read the error message displayed
216 when you run httpd. You should also check the server
217 error_log for additional information (with the default configuration,
218 this will be located in the file <CODE>error_log</CODE> in the
219 <CODE>logs</CODE> directory).
220
221 <P>
222
223 If you want your server to continue running after a system reboot, you
224 should add a call to <CODE>httpd</CODE> to your system startup files
225 (typically <CODE>rc.local</CODE> or a file in an
226 <CODE>rc.<EM>N</EM></CODE> directory). This will start Apache as root.
227 Before doing this ensure that your server is properly configured
228 for security and access restrictions.
229
230 <P>
231
232 To stop Apache send the parent process a TERM signal. The PID of this
233 process is written to the file <CODE>httpd.pid</CODE> in the
234 <CODE>logs</CODE> directory (unless configured otherwise).  Do not
235 attempt to kill the child processes because they will be renewed by
236 the parent.  A typical command to stop the server is:
237
238 <PRE>
239     kill -TERM `cat /usr/local/apache/logs/httpd.pid`
240 </PRE>
241
242 <P>
243
244 For more information about Apache command line options, configuration
245 and log files, see <A HREF="invoking.html">Starting Apache</A>. For a
246 reference guide to all Apache directives supported by the distributed
247 modules, see the <A HREF="mod/directives.html">Apache directives</A>.
248
249 <H2>Compiling Support Programs</H2>
250
251 In addition to the main <CODE>httpd</CODE> server which is compiled
252 and configured as above, Apache includes a number of support programs.
253 These are not compiled by default. The support programs are in the
254 <CODE>support</CODE> directory of the distribution. To compile
255 the support programs, change into this directory and type
256 <PRE>
257     make
258 </PRE>
259
260 <!--#include virtual="footer.html" -->
261 </BODY>
262 </HTML>