]> granicus.if.org Git - apache/blob - docs/manual/install.html
Major update of install.html.
[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</H1>
18
19
20 <p>This document covers compilation and installation of Apache on Unix
21 and Unix-like systems only. For compiling and installation on Windows,
22 see <A HREF="platform/windows.html">Using Apache with Microsoft
23 Windows</A>.  For other platforms, see the <a
24 href="platform/">platform</a> documentation.</p>
25
26 <p>Apache 2.0's configuration and installation environment has changed
27 completely from Apache 1.3.  Apache 1.3 used a custom set of scripts
28 to achieve easy installation.  Apache 2.0 now uses libtool and
29 autoconf to create an environment that looks like many other Open
30 Source projects.</p>
31
32 <h3>Overview for the impatient</h3>
33
34 <table>
35 <tr><td><a href="#download">Download</a></td>
36 <td><code>$ lynx http://www.apache.org/dist/httpd/httpd-2_0_<em>NN</em>.tar.gz
37 </code></td></tr>
38
39 <tr><td><a href="#extract">Extract</a></td>
40 <td><code>$ gzip -d httpd-2_0_<em>NN</em>.tar.gz<br>
41 $ tar xvf httpd-2_0_<em>NN</em>.tar
42 </code></td></tr>
43
44 <tr><td><a href="#configure">Configure</a></td>
45 <td><code>$ ./configure --prefix=<em>PREFIX</em>
46 </code></td></tr>
47
48 <tr><td><a href="#compile">Compile</a></td>
49 <td><code>$ make
50 </code></td></tr>
51
52 <tr><td><a href="#install">Install</a></td>
53 <td><code>$ make install
54 </code></td></tr>
55
56 <tr><td><a href="#customize">Customize</a></td>
57 <td><code>$ vi <em>PREFIX</em>/conf/httpd.conf
58 </code></td></tr>
59
60 <tr><td><a href="#test">Test</a></td>
61 <td><code>$ <em>PREFIX</em>/bin/apachectl start
62 </code></td></tr>
63
64 </table>
65
66 <p><em>NN</em> must be replaced with the current minor version number,
67 and <em>PREFIX</em> must be replaced with the filesystem path under
68 which the server should be installed.  If <em>PREFIX</em> is not
69 specified, it defaults to <code>/usr/local/apache2</code>.</p>
70
71 <p>Each section of the compilation and installation process is
72 described in more detail below, beginning with the requirements
73 for compiling and installing Apache HTTPD.</p>
74
75 <h3>Requirements</h3>
76
77 <p>The following requirements exist for building Apache:</p>
78
79 <ul>
80
81 <li>Disk Space<br><br> Make sure you have at least 50 MB of temporary
82 free disk space available.  After installation Apache occupies
83 approximately 10 MB of disk space.  The actual disk space requirements
84 will vary considerably based on your chosen configuration options and
85 any third-party modules.<br><br></li>
86
87 <li>ANSI-C Compiler and Build System<br><br> Make sure you have an
88 ANSI-C compiler installed. The <a
89 href="http://www.gnu.org/software/gcc/gcc.html">GNU C compiler
90 (GCC)</a> from the <a href="http://www.gnu.org/">Free Software
91 Foundation (FSF)</a> is recommended (version 2.7.2 is fine). If you
92 don't have GCC then at least make sure your vendors compiler is ANSI
93 compliant.  In addition, your <code>PATH</code> must contain basic
94 build tools such as <code>make</code>.<br><br></li>
95
96 <li>Accurate time keeping<br><br> Elements of the HTTP protocol are
97 expressed as the time of day.  So, it's time to investigate setting
98 some time synchronization facility on your system. Usually the ntpdate
99 or xntpd programs are used for this purpose which are based on the
100 Network Time Protocol (NTP). See the Usenet newsgroup <a
101 href="news:comp.protocols.time.ntp">comp.protocols.time.ntp</a> and
102 the <a href="http://www.eecis.udel.edu/~ntp/">NTP homepage</a> for more
103 details about NTP software and public time servers.<br><br></li>
104
105 <li><a href="http://www.perl.org/">Perl 5</a> [OPTIONAL]<br><br> For
106 some of the support scripts like <a href="programs/apxs.html">apxs</a>
107 or <a href="programs/dbmmanage.html">dbmmanage</a> (which are written
108 in Perl) the Perl 5 interpreter is required (versions 5.003 and 5.004
109 are fine). If no such interpreter is found by the `configure' script
110 there is no harm.  Of course, you still can build and install Apache
111 2.0. Only those support scripts cannot be used. If you have multiple
112 Perl interpreters installed (perhaps a Perl 4 from the vendor and a
113 Perl 5 from your own), then it is recommended to use the --with-perl
114 option (see below) to make sure the correct one is selected by
115 ./configure.  <br><br></li>
116
117 </ul>
118
119 <h3><a name="download">Download</a></h3>
120
121 <p>Apache can be downloaded from the <a
122 href="http://www.apache.org/dist/httpd/">Apache Software Foundation
123 download site</a> or from a <a
124 href="http://www.apache.org/dyn/closer.cgi">nearby mirror</a>.</p>
125
126 <p>Version numbers that end in <code>alpha</code> indicate early
127 pre-test versions which may or may not work.  Version numbers ending
128 in <code>beta</code> indicate more reliable releases that still
129 require further testing or bug fixing.  If you wish to dowload the
130 best available production release of the Apache HTTP Server, you
131 should choose the latest version with neither <code>alpha</code> nor
132 <code>beta</code> in its filename.</p>
133
134 <p>After downloading, especially if a mirror site is used, it is
135 important to verify that you have a complete and unmodified version
136 of the Apache HTTP Server.  This can be accomplished by testing the
137 downloaded tarball against the PGP signature, which should always be
138 obtained from the <a href="http://www.apache.org/dist/httpd">main
139 Apache website</a>.  The signature file has a filename identical to
140 the source tarball with the addition of <code>.asc</code>.</p>
141
142 <h3><a name="extract">Extract</a></h3>
143
144 <p>Extracting the source from the Apache HTTPD tarball is a simple
145 matter of uncompressing, and then untarring:</p>
146
147 <blockquote><code>
148 $ gzip -d httpd-2_0_<em>NN</em>.tar.gz<br>
149 $ tar xvf httpd-2_0_<em>NN</em>.tar
150 </code></blockquote>
151
152 <p>This will create a new directory under the current directory
153 containing the source code for the distribution.  You should
154 <code>cd</code> into that directory before proceeding with
155 compiling the server.</p>
156
157 <h3><a name="configure">Configuring the source tree</a></h3>
158
159 <p>The next step is to configure the Apache source tree for your
160 particular platform and personal requirements. This is done using the
161 script <code>configure</code> included in the root directory of the
162 distribution.  (Developers downloading the CVS version of the Apache
163 source tree will need to have <code>autoconf</code> and
164 <code>libtool</code> installed and will need to run
165 <code>buildconf</code> before proceeding with the next steps.  This is
166 not necessary for official releases.)</p>
167
168 <p>To configure the source tree using all the default options, simply
169 type <code>./configure</code>.  To change the default options,
170 <code>configure</code> accepts a variety of variables and command line
171 options.  Environment variables are generally placed before the
172 <code>./configure</code> command, while other options are placed
173 after.  The most important option here is the location prefix where
174 Apache is to be installed later, because Apache has to be configured
175 for this location to work correctly. But there are a lot of other
176 options available for your pleasure.</p>
177
178 <p>For a short impression of what possibilities you have, here is a
179 typical example which compiles Apache for the installation tree
180 /sw/pkg/apache with a particular compiler and flags plus the two
181 additional modules mod_rewrite and mod_speling for later loading
182 through the DSO mechanism:</p>
183
184 <blockquote><code>
185      $ CC="pgcc" CFLAGS="-O2" \<br>
186        ./configure --prefix=/sw/pkg/apache \<br>
187                    --enable-rewrite=shared \<br>
188                    --enable-speling=shared
189 </code></blockquote>
190
191 <p>When configure is run it will take several minutes to test for
192 the availability of features on your system and build Makefiles
193 which will later be used to compile the server.</p>
194
195 <p>The easiest way to find all of the configuration flags for Apache
196 is to run ./configure --help.  What follows is a brief description
197 of most of the arguments and environment variables.</p>
198
199 <h4>Environment Variables</h4>
200
201 <p>The autoconf build process uses several environment variables to
202 configure the build environment.  In general, these variables change
203 the method used to build Apache, but not the eventual features of the
204 server.  These variables can be placed in the environment before
205 invoking <code>configure</code>, but it is usually easier to specify
206 them on the <code>configure</code> command line as demonstrated 
207 in the example above.</p>
208
209 <dl>
210
211 <dt><code>CC=...</code></dt>
212 <dd>The name of the C compiler command.</dd>
213
214 <dt><code>CPPFLAGS=...</code></dt> <dd>Miscellaneous C preprocessor
215 and compiler options.</dd>
216
217 <dt><code>CFLAGS=...</code></dt>
218 <dd>Debugging and optimization options for the C compiler.</dd>
219
220 <dt><code>LDFLAGS=...</code></dt>
221 <dd>Miscellaneous options to be passed to the linker.</dd>
222
223 <dt><code>LIBS=...</code></dt>
224 <dd>Library location information ("-L" and "-l" options)
225 to pass to the linker.</dd>
226
227 <dt><code>INCLUDES=...</code></dt>
228 <dd>Header file search directories ("-I<em>dir</em>").</dd>
229
230 <dt><code>TARGET=...</code> [Default: apache]</dt>
231 <dd>Name of the executable which will be built.</dd>
232
233 <dt><code>NOTEST_CPPFLAGS=...</code></dt>
234 <dt><code>NOTEST_CFLAGS=...</code></dt>
235 <dt><code>NOTEST_LDFLAGS=...</code></dt>
236 <dt><code>NOTEST_LIBS=...</code></dt>
237 <dd>These variables share the same function as their non-NOTEST namesakes.
238 However, the variables are applied to the build process only after
239 autoconf has performed its feature testing.  This allows the inclusion of
240 flags which will cause problems during feature testing, but must be used
241 for the final compilation.</dd>
242
243 <dt><code>SHLIB_PATH=...</code></dt> 
244 <dd>Options which specify shared library paths for the compiler and
245 linker.</dd>
246
247 </dl>
248
249 <h4>autoconf Output Options</h4>
250
251 <dl>
252
253 <dt><code>--help</code></dt>
254 <dd>Prints the usage message including all available options, but 
255 does not actually configure anything.</dd>
256
257 <dt><code>--quiet</code></dt>
258 <dd>Prevents the printing of the usual "checking..." messages.</dd>
259
260 <dt><code>--verbose</code></dt>
261 <dd>Prints much more information during the configuration process,
262 including the names of all the files examined.</dd>
263
264 </dl>
265
266 <h4>Pathnames</h4>
267
268 <p>There are currently two ways to configure the pathnames under
269 which Apache will install its files.  First, you can specify
270 a directory and have Apache install itself under that directory
271 in its default locations.</p>
272
273 <dl>
274 <dt><code>--prefix=<em>PREFIX</em></code> [Default:
275 /usr/local/apache2]</dt> 
276 <dd>Specifies the directory under which the Apache files will be
277 installed.</dd>
278 </dl>
279
280 <p>It is possible to specify that architecture-dependent files should
281 be placed under a different directory.</p>
282
283 <dl>
284 <dt><code>--exec-prefix=<em>EPREFIX</em></code> [Default:
285 <em>PREFIX</em>]</dt> 
286 <dd>Specifies the directory under which architecture-dependent files
287 will be placed.</dd>
288 </dl>
289
290 <p>The second, and more flexible way to configure the install path
291 locations for Apache is using the <code>config.layout</code> file.
292 Using this method, it is possible to separately specify the location
293 for each type of file within the Apache installation.  The
294 <code>config.layout</code> file contains several example
295 configurations, and you can also create your own custom configuration
296 following the examples.  The different layouts in this file are
297 grouped into <code>&lt;Layout FOO&gt;...&lt;/Layout&gt;</code>
298 sections and referred to by name as in <code>FOO</code>.</p>
299
300 <dl>
301
302 <dt><code>--enable-layout=<em>LAYOUT</em></code></dt>
303 <dd>Use the named layout in the <code>config.layout</code> file
304 to specify the installation paths.</dd>
305
306 </dl>
307
308 <p>Presently it is not possible to mix the
309 <code>--enable-layout</code> and <code>--prefix</code> options.  Nor
310 is it possible to individually specify detailed pathnames on the
311 <code>configure</code> command line.  If you want just a basic
312 install, you can simply use the <code>--prefix</code> option on its
313 own.  If you want to customize your install, you should edit the
314 <code>config.layout</code> file and use the
315 <code>--enable-layout</code> option.</p>
316
317 <h4>Modules</h4>
318
319 <p>Apache is a modular server.  Only the most basic functionality is
320 included in the core server.  Extended features are available in
321 various modules.  During the configuration process, you must select
322 which modules to compile for use with your server.  You can view a <a
323 href="mod/index-bytype.html">list of modules</a> included in the
324 documentation.  Those modules with a <a
325 href="mod/module-dict.html#Status">status</a>
326 of "Base" are included by default and must be specifically disabled if
327 you do not want them.  Modules with any other status must be
328 specifically enabled if you wish to use them.</p>
329
330 <p>There are two ways for a module to be compiled and used with
331 Apache.  Modules may be <em>statically compiled</em>, which means that
332 they are permanently included in the Apache binary.  Alternatively, if
333 your operating system supports Dynamic Shared Objects (DSOs) and
334 autoconf can detect that support, then modules may be <em>dynamically
335 compiled</em>.  DSO modules are stored separately from the Apache
336 binary, and may be included or excluded from the server using the
337 run-time configuration directives provided by <a
338 href="mod/mod_so.html">mod_so</a>.  The mod_so is automatically
339 included in the server if any dynamic modules are included in the
340 compilation.  If you would like to make your server capable of loading
341 DSOs without actually compiling any dynamic modules, you can
342 explicitly <code>--enable-so</code>.</p>
343
344 <dl>
345
346 <dt><code>--enable-<em>MODULE</em>[=shared]</code></dt> <dd>Compile
347 and include the module <em>MODULE</em>.  The identifier
348 <em>MODULE</em> is the <a
349 href="mod/module-dict.html#ModuleIdentifier"
350 >Module Identifier</a> from the module documentation without the
351 "_module" string.  To compile the module dynamically as a DSO, add the
352 option <code>=shared</code>.</dd>
353
354 <dt><code>--disable-<em>MODULE</em></code></dt>
355 <dd>Remove the module <em>MODULE</em> which would otherwise be
356 compiled and included.</dd>
357
358 </dl>
359
360 <p>In addition to the standard set of modules, Apache 2.0 also
361 includes a choice of <a href="mpm.html">Multi-Processing Modules</a>
362 (MPMs).  One, and only one MPM must be included in the compilation
363 process.  The default MPMs for each platform are listed on the <a
364 href="mpm.html">MPM documentation page</a>, but can be overridden
365 on the <code>configure</code> command line.
366
367 <dl>
368
369 <dt><code>--with-mpm=<em>NAME</em></code></dt>
370 <dd>Choose the mpm <em>NAME</em>.
371
372 </dl>
373
374 <h4>Suexec</h4>
375
376 <p>Apache includes a support program called <a
377 href="suexec.html">suexec</a> which can be used to isolate user CGI
378 programs.  However, if suexec is improperly configured, it can cause
379 serious security problems.  Therefore, you should carefully read and
380 consider the <a href="suexec.html">suexec documentation</a> before
381 implementing this feature.</p>
382  
383
384 <h3><a name="compile">Building the package</a></h3>
385      
386 <p>Now you can build the various parts which form the Apache package
387 by simply running the command:</p>
388  
389 <blockquote><code>
390         $ make 
391 </code></blockquote>
392
393 <p>Please be patient here, since a base configuration takes
394 approximately 3 minutes to compile under a Pentium III/Linux 2.2
395 system, but this will vary widely depending on your hardware and the
396 number of modules which you have enabled.</p>
397
398  
399 <h3><a name="install">Installing the package</a></h3>
400      
401 <p>Now its time to install the package under the configured
402 installation PREFIX (see <code>--prefix</code> option above) by running:</h3>
403 <blockquote><code>
404         $ make install
405 </code></blockquote> 
406
407 <p>If you are upgrading, the installation will not overwrite 
408 your configuration files or documents.</p>
409
410
411 <h3><a name="customize">Customizing the package</a></h3>
412  
413 <p>Next, you can customize your Apache HTTP server by editing the <a
414 href="configuring.html">configuration files</a> under
415 PREFIX/conf/.</p> 
416
417 <blockquote><code> 
418 $ vi PREFIX/conf/httpd.conf
419 </code></blockquote>
420
421 <p>Have a look at the Apache manual under <a
422 href="./">docs/manual/</a> or <a
423 href="http://httpd.apache.org/docs/">http://httpd.apache.org/docs/</a>
424 for a complete reference of available <a
425 href="mod/directives.html">configuration directives</a>.</p>
426
427 <h3><a name="test">Testing the package</a></h3>
428  
429 <p>Now you can <a href="invoking.html">start</a> your Apache HTTP
430 server by immediately running:</p>
431
432 <blockquote><code>
433         $ PREFIX/bin/apachectl start
434 </code></blockquote>
435  
436 <p>and then you should be able to request your first document via URL
437 http://localhost/ (when you built and installed Apache as root) or
438 http://localhost:8080/ (when you built and installed Apache as a
439 regular user).  The web page you see is located under the <a
440 href="mod/core.html#documentroot">DocumentRoot</a> which will usually
441 be <code>PREFIX/htdocs/</code>.  Then <a href="stopping.html">stop</a>
442 the server again by running:</p>
443
444 <blockquote><code> $ PREFIX/bin/apachectl stop </code></blockquote>
445
446
447 <!--#include virtual="footer.html" -->
448 </BODY>
449 </HTML>