1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7 --><title>Compiling and Installing - Apache HTTP Server</title><link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /><link href="./images/favicon.ico" rel="shortcut icon" /></head><body id="manual-page"><div id="page-header"><p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p><p class="apache">Apache HTTP Server Version 2.0</p><img alt="" src="./images/feather.gif" /></div><div class="up"><a href="./"><img title="<-" alt="<-" src="./images/left.gif" /></a></div><div id="path"><a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="./">Version 2.0</a></div><div id="page-content"><div id="preamble"><h1>Compiling and Installing</h1>
9 <p>This document covers compilation and installation of Apache
10 on Unix and Unix-like systems only. For compiling and
11 installation on Windows, see <a href="platform/windows.html">Using Apache with Microsoft
12 Windows</a>. For other platforms, see the <a href="platform/">platform</a> documentation.</p>
14 <p>Apache 2.0's configuration and installation environment has
15 changed completely from Apache 1.3. Apache 1.3 used a custom
16 set of scripts to achieve easy installation. Apache 2.0 now
17 uses libtool and autoconf to create an environment that looks
18 like many other Open Source projects.</p>
20 </div><div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#overview">Overview for the
21 impatient</a></li><li><img alt="" src="./images/down.gif" /> <a href="#requirements">Requirements</a></li><li><img alt="" src="./images/down.gif" /> <a href="#download">Download</a></li><li><img alt="" src="./images/down.gif" /> <a href="#extract">Extract</a></li><li><img alt="" src="./images/down.gif" /> <a href="#configure">Configuring the source tree</a></li><li><img alt="" src="./images/down.gif" /> <a href="#compile">Build</a></li><li><img alt="" src="./images/down.gif" /> <a href="#install">Install</a></li><li><img alt="" src="./images/down.gif" /> <a href="#customize">Customize</a></li><li><img alt="" src="./images/down.gif" /> <a href="#test">Test</a></li></ul></div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="overview" id="overview">Overview for the
26 <td><a href="#download">Download</a></td>
29 http://www.apache.org/dist/httpd/httpd-2_0_<em>NN</em>.tar.gz</code>
34 <td><a href="#extract">Extract</a></td>
36 <td><code>$ gzip -d httpd-2_0_<em>NN</em>.tar.gz<br />
37 $ tar xvf httpd-2_0_<em>NN</em>.tar</code> </td>
41 <td><a href="#configure">Configure</a></td>
43 <td><code>$ ./configure --prefix=<em>PREFIX</em></code>
48 <td><a href="#compile">Compile</a></td>
50 <td><code>$ make</code> </td>
54 <td><a href="#install">Install</a></td>
56 <td><code>$ make install</code> </td>
60 <td><a href="#customize">Customize</a></td>
62 <td><code>$ vi <em>PREFIX</em>/conf/httpd.conf</code> </td>
66 <td><a href="#test">Test</a></td>
68 <td><code>$ <em>PREFIX</em>/bin/apachectl start</code>
73 <p><em>NN</em> must be replaced with the current minor version
74 number, and <em>PREFIX</em> must be replaced with the
75 filesystem path under which the server should be installed. If
76 <em>PREFIX</em> is not specified, it defaults to
77 <code>/usr/local/apache2</code>.</p>
79 <p>Each section of the compilation and installation process is
80 described in more detail below, beginning with the requirements
81 for compiling and installing Apache HTTPD.</p>
82 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="requirements" id="requirements">Requirements</a></h2>
84 <p>The following requirements exist for building Apache:</p>
89 Make sure you have at least 50 MB of temporary free disk
90 space available. After installation Apache occupies
91 approximately 10 MB of disk space. The actual disk space
92 requirements will vary considerably based on your chosen
93 configuration options and any third-party modules.<br />
97 <li>ANSI-C Compiler and Build System<br />
99 Make sure you have an ANSI-C compiler installed. The <a href="http://www.gnu.org/software/gcc/gcc.html">GNU C
100 compiler (GCC)</a> from the <a href="http://www.gnu.org/">Free Software Foundation (FSF)</a>
101 is recommended (version 2.7.2 is fine). If you don't have GCC
102 then at least make sure your vendor's compiler is ANSI
103 compliant. In addition, your <code>PATH</code> must contain
104 basic build tools such as <code>make</code>.<br />
108 <li>Accurate time keeping<br />
110 Elements of the HTTP protocol are expressed as the time of
111 day. So, it's time to investigate setting some time
112 synchronization facility on your system. Usually the ntpdate
113 or xntpd programs are used for this purpose which are based
114 on the Network Time Protocol (NTP). See the Usenet newsgroup
115 <a href="news:comp.protocols.time.ntp">comp.protocols.time.ntp</a>
116 and the <a href="http://www.eecis.udel.edu/~ntp/">NTP
117 homepage</a> for more details about NTP software and public
122 <li><a href="http://www.perl.org/">Perl 5</a>
125 For some of the support scripts like <a href="programs/apxs.html">apxs</a> or <a href="programs/dbmmanage.html">dbmmanage</a> (which are
126 written in Perl) the Perl 5 interpreter is required (versions
127 5.003 and 5.004 are fine). If no such interpreter is found by
128 the `configure' script there is no harm. Of course, you still
129 can build and install Apache 2.0. Only those support scripts
130 cannot be used. If you have multiple Perl interpreters
131 installed (perhaps a Perl 4 from the vendor and a Perl 5 from
132 your own), then it is recommended to use the --with-perl
133 option (see below) to make sure the correct one is selected
134 by ./configure.<br />
138 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="download" id="download">Download</a></h2>
140 <p>Apache can be downloaded from the <a href="http://www.apache.org/dist/httpd/">Apache Software
141 Foundation download site</a> or from a <a href="http://www.apache.org/dyn/closer.cgi/httpd/">nearby
144 <p>Version numbers that end in <code>alpha</code> indicate
145 early pre-test versions which may or may not work. Version
146 numbers ending in <code>beta</code> indicate more reliable
147 releases that still require further testing or bug fixing. If
148 you wish to download the best available production release of
149 the Apache HTTP Server, you should choose the latest version
150 with neither <code>alpha</code> nor <code>beta</code> in its
153 <p>After downloading, especially if a mirror site is used, it
154 is important to verify that you have a complete and unmodified
155 version of the Apache HTTP Server. This can be accomplished by
156 testing the downloaded tarball against the PGP signature. This,
157 in turn, is a two step procedure. First, you must obtain the
158 <code>KEYS</code> file from the <a href="http://www.apache.org/dist/httpd/">Apache distribution
159 site</a>. (To assure that the <code>KEYS</code> file itself has
160 not been modified, it may be a good idea to use a file from a
161 previous distribution of Apache or import the keys from a
162 public key server.) The keys are imported into your personal
163 key ring using one of the following commands (depending on your
166 <div class="example"><p><code>$ pgp < KEYS</code></p></div>
170 <div class="example"><p><code>$ gpg --import KEYS</code></p></div>
172 <p>The next step is to test the tarball against the PGP
173 signature, which should always be obtained from the <a href="http://www.apache.org/dist/httpd/">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>
179 <div class="example"><p><code>$ pgp httpd-2_0_<em>NN</em>.tar.gz.asc</code></p></div>
183 <div class="example"><p><code>$ gpg --verify httpd-2_0_<em>NN</em>.tar.gz.asc</code></p></div>
185 <p>You should receive a message like</p>
187 <div class="example"><p><code>Good signature from user "Martin Kraemer
188 <martin@apache.org>".</code></p></div>
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>
196 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="extract" id="extract">Extract</a></h2>
198 <p>Extracting the source from the Apache HTTPD tarball is a
199 simple matter of uncompressing, and then untarring:</p>
201 <div class="example"><p><code>
202 $ gzip -d httpd-2_0_<em>NN</em>.tar.gz<br />
203 $ tar xvf httpd-2_0_<em>NN</em>.tar
206 <p>This will create a new directory under the current directory
207 containing the source code for the distribution. You should
208 <code>cd</code> into that directory before proceeding with
209 compiling the server.</p>
210 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="configure" id="configure">Configuring the source tree</a></h2>
212 <p>The next step is to configure the Apache source tree for
213 your particular platform and personal requirements. This is
214 done using the script <code>configure</code> included in the
215 root directory of the distribution. (Developers downloading the
216 CVS version of the Apache source tree will need to have
217 <code>autoconf</code> and <code>libtool</code> installed and
218 will need to run <code>buildconf</code> before proceeding with
219 the next steps. This is not necessary for official
222 <p>To configure the source tree using all the default options,
223 simply type <code>./configure</code>. To change the default
224 options, <code>configure</code> accepts a variety of variables
225 and command line options. Environment variables are generally
226 placed before the <code>./configure</code> command, while other
227 options are placed after. The most important option here is the
228 location prefix where Apache is to be installed later, because
229 Apache has to be configured for this location to work
230 correctly. But there are a lot of other options available for
233 <p>For a short impression of what possibilities you have, here
234 is a typical example which compiles Apache for the installation
235 tree /sw/pkg/apache with a particular compiler and flags plus
236 the two additional modules mod_rewrite and mod_speling for
237 later loading through the DSO mechanism:</p>
239 <div class="example"><p><code>
240 $ CC="pgcc" CFLAGS="-O2" \<br />
241 ./configure --prefix=/sw/pkg/apache \<br />
242 --enable-rewrite=shared \<br />
243 --enable-speling=shared
246 <p>When configure is run it will take several minutes to test
247 for the availability of features on your system and build
248 Makefiles which will later be used to compile the server.</p>
250 <p>The easiest way to find all of the configuration flags for
251 Apache is to run ./configure --help. What follows is a brief
252 description of most of the arguments and environment
255 <h3><a name="environment" id="environment">Environment Variables</a></h3>
257 <p>The autoconf build process uses several environment
258 variables to configure the build environment. In general, these
259 variables change the method used to build Apache, but not the
260 eventual features of the server. These variables can be placed
261 in the environment before invoking <code>configure</code>, but
262 it is usually easier to specify them on the
263 <code>configure</code> command line as demonstrated in the
267 <dt><code>CC=...</code></dt>
269 <dd>The name of the C compiler command.</dd>
271 <dt><code>CPPFLAGS=...</code></dt>
273 <dd>Miscellaneous C preprocessor and compiler options.</dd>
275 <dt><code>CFLAGS=...</code></dt>
277 <dd>Debugging and optimization options for the C
280 <dt><code>LDFLAGS=...</code></dt>
282 <dd>Miscellaneous options to be passed to the linker.</dd>
284 <dt><code>LIBS=...</code></dt>
286 <dd>Library location information ("-L" and "-l" options) to
287 pass to the linker.</dd>
289 <dt><code>INCLUDES=...</code></dt>
291 <dd>Header file search directories ("-I<em>dir</em>").</dd>
293 <dt><code>TARGET=...</code> [Default: apache]</dt>
295 <dd>Name of the executable which will be built.</dd>
297 <dt><code>NOTEST_CPPFLAGS=...</code></dt>
299 <dt><code>NOTEST_CFLAGS=...</code></dt>
301 <dt><code>NOTEST_LDFLAGS=...</code></dt>
303 <dt><code>NOTEST_LIBS=...</code></dt>
305 <dd>These variables share the same function as their
306 non-NOTEST namesakes. However, the variables are applied to
307 the build process only after autoconf has performed its
308 feature testing. This allows the inclusion of flags which
309 will cause problems during feature testing, but must be used
310 for the final compilation.</dd>
312 <dt><code>SHLIB_PATH=...</code></dt>
314 <dd>Options which specify shared library paths for the
315 compiler and linker.</dd>
319 <h3><a name="output" id="output">autoconf Output Options</a></h3>
322 <dt><code>--help</code></dt>
324 <dd>Prints the usage message including all available options,
325 but does not actually configure anything.</dd>
327 <dt><code>--quiet</code></dt>
329 <dd>Prevents the printing of the usual "checking..."
332 <dt><code>--verbose</code></dt>
334 <dd>Prints much more information during the configuration
335 process, including the names of all the files examined.</dd>
339 <h3><a name="pathnames" id="pathnames">Pathnames</a></h3>
341 <p>There are currently two ways to configure the pathnames
342 under which Apache will install its files. First, you can
343 specify a directory and have Apache install itself under that
344 directory in its default locations.</p>
347 <dt><code>--prefix=<em>PREFIX</em></code> [Default:
348 /usr/local/apache2]</dt>
350 <dd>Specifies the directory under which the Apache files will
354 <p>It is possible to specify that architecture-dependent files
355 should be placed under a different directory.</p>
358 <dt><code>--exec-prefix=<em>EPREFIX</em></code> [Default:
359 <em>PREFIX</em>]</dt>
361 <dd>Specifies the directory under which
362 architecture-dependent files will be placed.</dd>
365 <p>The second, and more flexible way to configure the install
366 path locations for Apache is using the
367 <code>config.layout</code> file. Using this method, it is
368 possible to separately specify the location for each type of
369 file within the Apache installation. The
370 <code>config.layout</code> file contains several example
371 configurations, and you can also create your own custom
372 configuration following the examples. The different layouts in
373 this file are grouped into <code><Layout
374 FOO>...</Layout></code> sections and referred to by
375 name as in <code>FOO</code>.</p>
378 <dt><code>--enable-layout=<em>LAYOUT</em></code></dt>
380 <dd>Use the named layout in the <code>config.layout</code>
381 file to specify the installation paths.</dd>
384 <p>Presently it is not possible to mix the
385 <code>--enable-layout</code> and <code>--prefix</code> options.
386 Nor is it possible to individually specify detailed pathnames
387 on the <code>configure</code> command line. If you want just a
388 basic install, you can simply use the <code>--prefix</code>
389 option on its own. If you want to customize your install, you
390 should edit the <code>config.layout</code> file and use the
391 <code>--enable-layout</code> option.</p>
394 <h3><a name="modules" id="modules">Modules</a></h3>
396 <p>Apache is a modular server. Only the most basic
397 functionality is included in the core server. Extended features
398 are available in various modules. During the configuration
399 process, you must select which modules to compile for use with
400 your server. You can view a <a href="mod/index.html">list of modules</a> included in
401 the documentation. Those modules with a <a 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. Modules with any other status must be
404 specifically enabled if you wish to use them.</p>
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 autoconf 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 <code class="module"><a href="./mod/mod_so.html">mod_so</a></code>.
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>
422 <dt><code>--enable-<em>MODULE</em>[=shared]</code></dt>
424 <dd>Compile and include the module <em>MODULE</em>. The
425 identifier <em>MODULE</em> is the <a href="mod/module-dict.html#ModuleIdentifier">Module
426 Identifier</a> from the module documentation without the
427 "_module" string. To compile the module as a DSO, add the
428 option <code>=shared</code>.</dd>
430 <dt><code>--disable-<em>MODULE</em></code></dt>
432 <dd>Remove the module <em>MODULE</em> which would otherwise
433 be compiled and included.</dd>
435 <dt><code>--enable-modules=<em>MODULE-LIST</em></code></dt>
437 <dd>Compile and include the modules listed in the
438 space-separated <em>MODULE-LIST</em>.</dd>
441 <code>--enable-mods-shared=<em>MODULE-LIST</em></code></dt>
443 <dd>Compile and include the modules in the space-separated
444 <em>MODULE-LIST</em> as dynamically loadable (DSO)
448 <p>The <em>MODULE-LIST</em> in the
449 <code>--enable-modules</code> and
450 <code>--enable-mods-shared</code> options is usually a
451 space-separated list of module identifiers. For example, to
452 enable mod_dav and mod_info, you can either use</p>
454 <div class="example"><p><code>./configure --enable-dav --enable-info</code></p></div>
456 <p>or, equivalently,</p>
458 <div class="example"><p><code>./configure --enable-modules="dav info"</code></p></div>
460 <p>In addition, the special keywords <code>all</code> or
461 <code>most</code> can be used to add all or most of the modules
462 in one step. You can then remove any modules that you do not
463 want with the <code>--disable-<em>MODULE</em></code> option.
464 For example, to include all modules as DSOs with the exception
465 of mod_info, you can use</p>
467 <div class="example"><p><code>
468 ./configure --enable-mods-shared=all
472 <p>In addition to the standard set of modules, Apache 2.0 also
473 includes a choice of <a href="mpm.html">Multi-Processing
474 Modules</a> (MPMs). One, and only one MPM must be included in
475 the compilation process. The default MPMs for each platform are
476 listed on the <a href="mpm.html">MPM documentation page</a>,
477 but can be overridden on the <code>configure</code> command
481 <dt><code>--with-mpm=<em>NAME</em></code></dt>
483 <dd>Choose the mpm <em>NAME</em>.</dd>
487 <h3><a name="dbm" id="dbm">DBM</a></h3>
489 <p>Several Apache features, including
490 <code class="module"><a href="./mod/mod_auth_dbm.html">mod_auth_dbm</a></code> and <code class="module"><a href="./mod/mod_rewrite.html">mod_rewrite</a></code>'s
491 DBM <code class="directive"><a href="./mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> use
492 simple key/value databases for quick lookups of information. Apache
493 includes SDBM with its source-code, so this database is always
494 available. If you would like to use other database types, the
495 following <code>configure</code> options are available:</p>
498 <dt><code>--with-gdbm[=<em>path</em>]</code></dt>
499 <dt><code>--with-ndbm[=<em>path</em>]</code></dt>
500 <dt><code>--with-berkeley-db[=<em>path</em>]</code></dt>
502 <dd>If no <em>path</em> is specified, Apache will search for the
503 include files and libraries in the usual search paths. An explict
504 <em>path</em> will cause Apache to look in
505 <em>path</em><code>/lib</code> and
506 <em>path</em><code>/include</code> for the relevant files. Finally,
507 the <em>path</em> may specify specific include and library paths
508 seperated by a colon.</dd>
513 <h3><a name="suexec" id="suexec">Suexec</a></h3>
515 <p>Apache includes a support program called <a href="suexec.html">suexec</a> which can be used to isolate user
516 CGI programs. However, if suexec is improperly configured, it
517 can cause serious security problems. Therefore, you should
518 carefully read and consider the <a href="suexec.html">suexec
519 documentation</a> before implementing this feature.</p>
521 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="compile" id="compile">Build</a></h2>
523 <p>Now you can build the various parts which form the Apache
524 package by simply running the command:</p>
526 <div class="example"><p><code>$ make</code></p></div>
528 <p>Please be patient here, since a base configuration takes
529 approximately 3 minutes to compile under a Pentium III/Linux
530 2.2 system, but this will vary widely depending on your
531 hardware and the number of modules which you have enabled.</p>
532 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="install" id="install">Install</a></h2>
534 <p>Now its time to install the package under the configured
535 installation <em>PREFIX</em> (see <code>--prefix</code> option
536 above) by running:</p>
538 <div class="example"><p><code>$ make install</code></p></div>
540 <p>If you are upgrading, the installation will not overwrite
541 your configuration files or documents.</p>
542 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="customize" id="customize">Customize</a></h2>
544 <p>Next, you can customize your Apache HTTP server by editing
545 the <a href="configuring.html">configuration files</a> under
546 <em>PREFIX</em>/conf/.</p>
548 <div class="example"><p><code>$ vi <em>PREFIX</em>/conf/httpd.conf</code></p></div>
550 <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>
551 for a complete reference of available <a href="mod/directives.html">configuration directives</a>.</p>
552 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="test" id="test">Test</a></h2>
554 <p>Now you can <a href="invoking.html">start</a> your Apache
555 HTTP server by immediately running:</p>
557 <div class="example"><p><code>$ <em>PREFIX</em>/bin/apachectl start</code></p></div>
559 <p>and then you should be able to request your first document
560 via URL http://localhost/. The web page you see is located
561 under the <code class="directive"><a href="./mod/core.html#documentroot">DocumentRoot</a></code>
562 which will usually be <code><em>PREFIX</em>/htdocs/</code>.
563 Then <a href="stopping.html">stop</a> the server again by
566 <div class="example"><p><code>$ <em>PREFIX</em>/bin/apachectl stop</code></p></div>
567 </div></div><div id="footer"><p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p><p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div></body></html>