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