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