1 <html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><!--
2 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
3 This file is generated from xml source: DO NOT EDIT
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 --><title>Compiling and Installing - Apache HTTP Server</title><link href="./style/manual.css" type="text/css" rel="stylesheet"></head><body><blockquote><div align="center"><img src="./images/sub.gif" alt="[APACHE DOCUMENTATION]"><h3>Apache HTTP Server Version 2.0</h3></div><h1 align="center">Compiling and Installing</h1>
7 <p>This document covers compilation and installation of Apache
8 on Unix and Unix-like systems only. For compiling and
9 installation on Windows, see <a href="platform/windows.html">Using Apache with Microsoft
10 Windows</a>. For other platforms, see the <a href="platform/">platform</a> documentation.</p>
12 <p>Apache 2.0's configuration and installation environment has
13 changed completely from Apache 1.3. Apache 1.3 used a custom
14 set of scripts to achieve easy installation. Apache 2.0 now
15 uses libtool and autoconf to create an environment that looks
16 like many other Open Source projects.</p>
18 <ul><li><a href="#overview">Overview for the
19 impatient</a></li><li><a href="#requirements">Requirements</a></li><li><a href="#download">Download</a></li><li><a href="#extract">Extract</a></li><li><a href="#configure">Configuring the source tree</a><ul><li><a href="#environment">Environment Variables</a></li><li><a href="#output">autoconf Output Options</a></li><li><a href="#pathnames">Pathnames</a></li><li><a href="#modules">Modules</a></li><li><a href="#dbm">DBM</a></li><li><a href="#suexec">Suexec</a></li></ul></li><li><a href="#compile">Build</a></li><li><a href="#install">Install</a></li><li><a href="#customize">Customize</a></li><li><a href="#test">Test</a></li></ul><hr><h2><a name="overview">Overview for the
24 <td><a href="#download">Download</a></td>
27 http://www.apache.org/dist/httpd/httpd-2_0_<em>NN</em>.tar.gz</code>
32 <td><a href="#extract">Extract</a></td>
34 <td><code>$ gzip -d httpd-2_0_<em>NN</em>.tar.gz<br>
35 $ tar xvf httpd-2_0_<em>NN</em>.tar</code> </td>
39 <td><a href="#configure">Configure</a></td>
41 <td><code>$ ./configure --prefix=<em>PREFIX</em></code>
46 <td><a href="#compile">Compile</a></td>
48 <td><code>$ make</code> </td>
52 <td><a href="#install">Install</a></td>
54 <td><code>$ make install</code> </td>
58 <td><a href="#customize">Customize</a></td>
60 <td><code>$ vi <em>PREFIX</em>/conf/httpd.conf</code> </td>
64 <td><a href="#test">Test</a></td>
66 <td><code>$ <em>PREFIX</em>/bin/apachectl start</code>
71 <p><em>NN</em> must be replaced with the current minor version
72 number, and <em>PREFIX</em> must be replaced with the
73 filesystem path under which the server should be installed. If
74 <em>PREFIX</em> is not specified, it defaults to
75 <code>/usr/local/apache2</code>.</p>
77 <p>Each section of the compilation and installation process is
78 described in more detail below, beginning with the requirements
79 for compiling and installing Apache HTTPD.</p>
80 <h2><a name="requirements">Requirements</a></h2>
82 <p>The following requirements exist for building Apache:</p>
87 Make sure you have at least 50 MB of temporary free disk
88 space available. After installation Apache occupies
89 approximately 10 MB of disk space. The actual disk space
90 requirements will vary considerably based on your chosen
91 configuration options and any third-party modules.<br>
95 <li>ANSI-C Compiler and Build System<br>
97 Make sure you have an ANSI-C compiler installed. The <a href="http://www.gnu.org/software/gcc/gcc.html">GNU C
98 compiler (GCC)</a> from the <a href="http://www.gnu.org/">Free Software Foundation (FSF)</a>
99 is recommended (version 2.7.2 is fine). If you don't have GCC
100 then at least make sure your vendor's compiler is ANSI
101 compliant. In addition, your <code>PATH</code> must contain
102 basic build tools such as <code>make</code>.<br>
106 <li>Accurate time keeping<br>
108 Elements of the HTTP protocol are expressed as the time of
109 day. So, it's time to investigate setting some time
110 synchronization facility on your system. Usually the ntpdate
111 or xntpd programs are used for this purpose which are based
112 on the Network Time Protocol (NTP). See the Usenet newsgroup
113 <a href="news:comp.protocols.time.ntp">comp.protocols.time.ntp</a>
114 and the <a href="http://www.eecis.udel.edu/~ntp/">NTP
115 homepage</a> for more details about NTP software and public
120 <li><a href="http://www.perl.org/">Perl 5</a>
123 For some of the support scripts like <a href="programs/apxs.html">apxs</a> or <a href="programs/dbmmanage.html">dbmmanage</a> (which are
124 written in Perl) the Perl 5 interpreter is required (versions
125 5.003 and 5.004 are fine). If no such interpreter is found by
126 the `configure' script there is no harm. Of course, you still
127 can build and install Apache 2.0. Only those support scripts
128 cannot be used. If you have multiple Perl interpreters
129 installed (perhaps a Perl 4 from the vendor and a Perl 5 from
130 your own), then it is recommended to use the --with-perl
131 option (see below) to make sure the correct one is selected
136 <h2><a name="download">Download</a></h2>
138 <p>Apache can be downloaded from the <a href="http://www.apache.org/dist/httpd/">Apache Software
139 Foundation download site</a> or from a <a href="http://www.apache.org/dyn/closer.cgi/httpd/">nearby
142 <p>Version numbers that end in <code>alpha</code> indicate
143 early pre-test versions which may or may not work. Version
144 numbers ending in <code>beta</code> indicate more reliable
145 releases that still require further testing or bug fixing. If
146 you wish to download the best available production release of
147 the Apache HTTP Server, you should choose the latest version
148 with neither <code>alpha</code> nor <code>beta</code> in its
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 href="http://www.apache.org/dist/httpd/">Apache distribution
157 site</a>. (To assure that the <code>KEYS</code> file itself has
158 not been modified, it may be a good idea to use a file from a
159 previous distribution of Apache or import the keys from a
160 public key server.) The keys are imported into your personal
161 key ring using one of the following commands (depending on your
164 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>$ pgp < KEYS</code></td></tr></table></blockquote>
168 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>$ gpg --import KEYS</code></td></tr></table></blockquote>
170 <p>The next step is to test the tarball against the PGP
171 signature, which should always be obtained from the <a href="http://www.apache.org/dist/httpd/">main Apache
172 website</a>. The signature file has a filename identical to the
173 source tarball with the addition of <code>.asc</code>. Then you
174 can check the distribution with one of the following commands
175 (again, depending on your pgp version):</p>
177 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>$ pgp httpd-2_0_<em>NN</em>.tar.gz.asc</code></td></tr></table></blockquote>
181 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>$ gpg --verify httpd-2_0_<em>NN</em>.tar.gz.asc</code></td></tr></table></blockquote>
183 <p>You should receive a message like</p>
185 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>Good signature from user "Martin Kraemer
186 <martin@apache.org>".</code></td></tr></table></blockquote>
188 <p>Depending on the trust relationships contained in your key
189 ring, you may also receive a message saying that the
190 relationship between the key and the signer of the key cannot
191 be verified. This is not a problem if you trust the
192 authenticity of the <code>KEYS</code> file.</p>
194 <h2><a name="extract">Extract</a></h2>
196 <p>Extracting the source from the Apache HTTPD tarball is a
197 simple matter of uncompressing, and then untarring:</p>
199 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
200 $ gzip -d httpd-2_0_<em>NN</em>.tar.gz<br>
201 $ tar xvf httpd-2_0_<em>NN</em>.tar
202 </code></td></tr></table></blockquote>
204 <p>This will create a new directory under the current directory
205 containing the source code for the distribution. You should
206 <code>cd</code> into that directory before proceeding with
207 compiling the server.</p>
208 <h2><a name="configure">Configuring the source tree</a></h2>
210 <p>The next step is to configure the Apache source tree for
211 your particular platform and personal requirements. This is
212 done using the script <code>configure</code> included in the
213 root directory of the distribution. (Developers downloading the
214 CVS version of the Apache source tree will need to have
215 <code>autoconf</code> and <code>libtool</code> installed and
216 will need to run <code>buildconf</code> before proceeding with
217 the next steps. This is not necessary for official
220 <p>To configure the source tree using all the default options,
221 simply type <code>./configure</code>. To change the default
222 options, <code>configure</code> accepts a variety of variables
223 and command line options. Environment variables are generally
224 placed before the <code>./configure</code> command, while other
225 options are placed after. The most important option here is the
226 location prefix where Apache is to be installed later, because
227 Apache has to be configured for this location to work
228 correctly. But there are a lot of other options available for
231 <p>For a short impression of what possibilities you have, here
232 is a typical example which compiles Apache for the installation
233 tree /sw/pkg/apache with a particular compiler and flags plus
234 the two additional modules mod_rewrite and mod_speling for
235 later loading through the DSO mechanism:</p>
237 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
238 $ CC="pgcc" CFLAGS="-O2" \<br>
239 ./configure --prefix=/sw/pkg/apache \<br>
240 --enable-rewrite=shared \<br>
241 --enable-speling=shared
242 </code></td></tr></table></blockquote>
244 <p>When configure is run it will take several minutes to test
245 for the availability of features on your system and build
246 Makefiles which will later be used to compile the server.</p>
248 <p>The easiest way to find all of the configuration flags for
249 Apache is to run ./configure --help. What follows is a brief
250 description of most of the arguments and environment
253 <h3><a name="environment">Environment Variables</a></h3>
255 <p>The autoconf build process uses several environment
256 variables to configure the build environment. In general, these
257 variables change the method used to build Apache, but not the
258 eventual features of the server. These variables can be placed
259 in the environment before invoking <code>configure</code>, but
260 it is usually easier to specify them on the
261 <code>configure</code> command line as demonstrated in the
265 <dt><code>CC=...</code></dt>
267 <dd>The name of the C compiler command.</dd>
269 <dt><code>CPPFLAGS=...</code></dt>
271 <dd>Miscellaneous C preprocessor and compiler options.</dd>
273 <dt><code>CFLAGS=...</code></dt>
275 <dd>Debugging and optimization options for the C
278 <dt><code>LDFLAGS=...</code></dt>
280 <dd>Miscellaneous options to be passed to the linker.</dd>
282 <dt><code>LIBS=...</code></dt>
284 <dd>Library location information ("-L" and "-l" options) to
285 pass to the linker.</dd>
287 <dt><code>INCLUDES=...</code></dt>
289 <dd>Header file search directories ("-I<em>dir</em>").</dd>
291 <dt><code>TARGET=...</code> [Default: apache]</dt>
293 <dd>Name of the executable which will be built.</dd>
295 <dt><code>NOTEST_CPPFLAGS=...</code></dt>
297 <dt><code>NOTEST_CFLAGS=...</code></dt>
299 <dt><code>NOTEST_LDFLAGS=...</code></dt>
301 <dt><code>NOTEST_LIBS=...</code></dt>
303 <dd>These variables share the same function as their
304 non-NOTEST namesakes. However, the variables are applied to
305 the build process only after autoconf has performed its
306 feature testing. This allows the inclusion of flags which
307 will cause problems during feature testing, but must be used
308 for the final compilation.</dd>
310 <dt><code>SHLIB_PATH=...</code></dt>
312 <dd>Options which specify shared library paths for the
313 compiler and linker.</dd>
317 <h3><a name="output">autoconf Output Options</a></h3>
320 <dt><code>--help</code></dt>
322 <dd>Prints the usage message including all available options,
323 but does not actually configure anything.</dd>
325 <dt><code>--quiet</code></dt>
327 <dd>Prevents the printing of the usual "checking..."
330 <dt><code>--verbose</code></dt>
332 <dd>Prints much more information during the configuration
333 process, including the names of all the files examined.</dd>
337 <h3><a name="pathnames">Pathnames</a></h3>
339 <p>There are currently two ways to configure the pathnames
340 under which Apache will install its files. First, you can
341 specify a directory and have Apache install itself under that
342 directory in its default locations.</p>
345 <dt><code>--prefix=<em>PREFIX</em></code> [Default:
346 /usr/local/apache2]</dt>
348 <dd>Specifies the directory under which the Apache files will
352 <p>It is possible to specify that architecture-dependent files
353 should be placed under a different directory.</p>
356 <dt><code>--exec-prefix=<em>EPREFIX</em></code> [Default:
357 <em>PREFIX</em>]</dt>
359 <dd>Specifies the directory under which
360 architecture-dependent files will be placed.</dd>
363 <p>The second, and more flexible way to configure the install
364 path locations for Apache is using the
365 <code>config.layout</code> file. Using this method, it is
366 possible to separately specify the location for each type of
367 file within the Apache installation. The
368 <code>config.layout</code> file contains several example
369 configurations, and you can also create your own custom
370 configuration following the examples. The different layouts in
371 this file are grouped into <code><Layout
372 FOO>...</Layout></code> sections and referred to by
373 name as in <code>FOO</code>.</p>
376 <dt><code>--enable-layout=<em>LAYOUT</em></code></dt>
378 <dd>Use the named layout in the <code>config.layout</code>
379 file to specify the installation paths.</dd>
382 <p>Presently it is not possible to mix the
383 <code>--enable-layout</code> and <code>--prefix</code> options.
384 Nor is it possible to individually specify detailed pathnames
385 on the <code>configure</code> command line. If you want just a
386 basic install, you can simply use the <code>--prefix</code>
387 option on its own. If you want to customize your install, you
388 should edit the <code>config.layout</code> file and use the
389 <code>--enable-layout</code> option.</p>
392 <h3><a name="modules">Modules</a></h3>
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 href="mod/index.html">list of modules</a> included in
399 the documentation. Those modules with a <a href="mod/module-dict.html#Status">status</a> of "Base" are
400 included by default and must be specifically disabled if you do
401 not want them. Modules with any other status must be
402 specifically enabled if you wish to use them.</p>
404 <p>There are two ways for a module to be compiled and used with
405 Apache. Modules may be <em>statically compiled</em>, which
406 means that they are permanently included in the Apache binary.
407 Alternatively, if your operating system supports Dynamic Shared
408 Objects (DSOs) and autoconf can detect that support, then
409 modules may be <em>dynamically compiled</em>. DSO modules are
410 stored separately from the Apache binary, and may be included
411 or excluded from the server using the run-time configuration
412 directives provided by <code><a href="./mod/mod_so.html">mod_so</a></code>.
413 The mod_so is automatically included in the server if any
414 dynamic modules are included in the compilation. If you would
415 like to make your server capable of loading DSOs without
416 actually compiling any dynamic modules, you can explicitly
417 <code>--enable-so</code>.</p>
420 <dt><code>--enable-<em>MODULE</em>[=shared]</code></dt>
422 <dd>Compile and include the module <em>MODULE</em>. The
423 identifier <em>MODULE</em> is the <a href="mod/module-dict.html#ModuleIdentifier">Module
424 Identifier</a> from the module documentation without the
425 "_module" string. To compile the module as a DSO, add the
426 option <code>=shared</code>.</dd>
428 <dt><code>--disable-<em>MODULE</em></code></dt>
430 <dd>Remove the module <em>MODULE</em> which would otherwise
431 be compiled and included.</dd>
433 <dt><code>--enable-modules=<em>MODULE-LIST</em></code></dt>
435 <dd>Compile and include the modules listed in the
436 space-separated <em>MODULE-LIST</em>.</dd>
439 <code>--enable-mods-shared=<em>MODULE-LIST</em></code></dt>
441 <dd>Compile and include the modules in the space-separated
442 <em>MODULE-LIST</em> as dynamically loadable (DSO)
446 <p>The <em>MODULE-LIST</em> in the
447 <code>--enable-modules</code> and
448 <code>--enable-mods-shared</code> options is usually a
449 space-separated list of module identifiers. For example, to
450 enable mod_dav and mod_info, you can either use</p>
452 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>./configure --enable-dav --enable-info</code></td></tr></table></blockquote>
454 <p>or, equivalently,</p>
456 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>./configure --enable-modules="dav info"</code></td></tr></table></blockquote>
458 <p>In addition, the special keywords <code>all</code> or
459 <code>most</code> can be used to add all or most of the modules
460 in one step. You can then remove any modules that you do not
461 want with the <code>--disable-<em>MODULE</em></code> option.
462 For example, to include all modules as DSOs with the exception
463 of mod_info, you can use</p>
465 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
466 ./configure --enable-mods-shared=all
468 </code></td></tr></table></blockquote>
470 <p>In addition to the standard set of modules, Apache 2.0 also
471 includes a choice of <a href="mpm.html">Multi-Processing
472 Modules</a> (MPMs). One, and only one MPM must be included in
473 the compilation process. The default MPMs for each platform are
474 listed on the <a href="mpm.html">MPM documentation page</a>,
475 but can be overridden on the <code>configure</code> command
479 <dt><code>--with-mpm=<em>NAME</em></code></dt>
481 <dd>Choose the mpm <em>NAME</em>.</dd>
485 <h3><a name="dbm">DBM</a></h3>
487 <p>Several Apache features, including
488 <code><a href="./mod/mod_auth_dbm.html">mod_auth_dbm</a></code> and <code><a href="./mod/mod_rewrite.html">mod_rewrite</a></code>'s
489 DBM <a href="./mod/mod_rewrite.html#rewritemap" class="directive"><code class="directive">RewriteMap</code></a> use
490 simple key/value databases for quick lookups of information. Apache
491 includes SDBM with its source-code, so this database is always
492 available. If you would like to use other database types, the
493 following <code>configure</code> options are available:</p>
496 <dt><code>--with-gdbm[=<em>path</em>]</code></dt>
497 <dt><code>--with-ndbm[=<em>path</em>]</code></dt>
498 <dt><code>--with-berkeley-db[=<em>path</em>]</code></dt>
500 <dd>If no <em>path</em> is specified, Apache will search for the
501 include files and libraries in the usual search paths. An explict
502 <em>path</em> will cause Apache to look in
503 <em>path</em><code>/lib</code> and
504 <em>path</em><code>/include</code> for the relevant files. Finally,
505 the <em>path</em> may specify specific include and library paths
506 seperated by a colon.</dd>
511 <h3><a name="suexec">Suexec</a></h3>
513 <p>Apache includes a support program called <a href="suexec.html">suexec</a> which can be used to isolate user
514 CGI programs. However, if suexec is improperly configured, it
515 can cause serious security problems. Therefore, you should
516 carefully read and consider the <a href="suexec.html">suexec
517 documentation</a> before implementing this feature.</p>
519 <h2><a name="compile">Build</a></h2>
521 <p>Now you can build the various parts which form the Apache
522 package by simply running the command:</p>
524 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>$ make</code></td></tr></table></blockquote>
526 <p>Please be patient here, since a base configuration takes
527 approximately 3 minutes to compile under a Pentium III/Linux
528 2.2 system, but this will vary widely depending on your
529 hardware and the number of modules which you have enabled.</p>
530 <h2><a name="install">Install</a></h2>
532 <p>Now its time to install the package under the configured
533 installation <em>PREFIX</em> (see <code>--prefix</code> option
534 above) by running:</p>
536 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>$ make install</code></td></tr></table></blockquote>
538 <p>If you are upgrading, the installation will not overwrite
539 your configuration files or documents.</p>
540 <h2><a name="customize">Customize</a></h2>
542 <p>Next, you can customize your Apache HTTP server by editing
543 the <a href="configuring.html">configuration files</a> under
544 <em>PREFIX</em>/conf/.</p>
546 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>$ vi <em>PREFIX</em>/conf/httpd.conf</code></td></tr></table></blockquote>
548 <p>Have a look at the Apache manual under <a href="./">docs/manual/</a> or <a href="http://httpd.apache.org/docs/">http://httpd.apache.org/docs-2.0/</a>
549 for a complete reference of available <a href="mod/directives.html">configuration directives</a>.</p>
550 <h2><a name="test">Test</a></h2>
552 <p>Now you can <a href="invoking.html">start</a> your Apache
553 HTTP server by immediately running:</p>
555 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>$ <em>PREFIX</em>/bin/apachectl start</code></td></tr></table></blockquote>
557 <p>and then you should be able to request your first document
558 via URL http://localhost/. The web page you see is located
559 under the <a href="./mod/core.html#documentroot" class="directive"><code class="directive">DocumentRoot</code></a>
560 which will usually be <code><em>PREFIX</em>/htdocs/</code>.
561 Then <a href="stopping.html">stop</a> the server again by
564 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>$ <em>PREFIX</em>/bin/apachectl stop</code></td></tr></table></blockquote>
565 <hr></blockquote><h3 align="center">Apache HTTP Server Version 2.0</h3><a href="./"><img src="./images/index.gif" alt="Index"></a><a href="./"><img src="./images/home.gif" alt="Home"></a></body></html>