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