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"?>
6 Copyright 2002-2004 The Apache Software Foundation
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
21 <manualpage metafile="install.xml.meta">
23 <title>Compiling and Installing</title>
27 <p>This document covers compilation and installation of Apache
28 on Unix and Unix-like systems only. For compiling and
29 installation on Windows, see <a
30 href="platform/windows.html">Using Apache with Microsoft
31 Windows</a>. For other platforms, see the <a
32 href="platform/">platform</a> documentation.</p>
34 <p>Apache 2.0's configuration and installation environment has
35 changed completely from Apache 1.3. Apache 1.3 used a custom
36 set of scripts to achieve easy installation. Apache 2.0 now
37 uses <code>libtool</code> and <code>autoconf</code>
38 to create an environment that looks like many other Open Source
41 <p>If you are upgrading from one minor version to the next (for
42 example, 2.0.50 to 2.0.51), please skip down to the <a
43 href="#upgrading">upgrading</a> section.</p>
47 <seealso><a href="invoking.html">Starting Apache</a></seealso>
48 <seealso><a href="stopping.html">Stopping and Restarting</a></seealso>
50 <section id="overview"><title>Overview for the
54 <columnspec><column width=".13"/><column width=".80"/></columnspec>
56 <td><a href="#download">Download</a></td>
58 <td><code>$ lynx http://httpd.apache.org/download.cgi</code>
63 <td><a href="#extract">Extract</a></td>
65 <td><code>$ gzip -d httpd-2_1_<em>NN</em>.tar.gz<br />
66 $ tar xvf httpd-2_1_<em>NN</em>.tar</code> </td>
70 <td><a href="#configure">Configure</a></td>
72 <td><code>$ ./configure --prefix=<em>PREFIX</em></code>
77 <td><a href="#compile">Compile</a></td>
79 <td><code>$ make</code> </td>
83 <td><a href="#install">Install</a></td>
85 <td><code>$ make install</code> </td>
89 <td><a href="#customize">Customize</a></td>
91 <td><code>$ vi <em>PREFIX</em>/conf/httpd.conf</code> </td>
95 <td><a href="#test">Test</a></td>
97 <td><code>$ <em>PREFIX</em>/bin/apachectl start</code>
102 <p><em>NN</em> must be replaced with the current minor version
103 number, and <em>PREFIX</em> must be replaced with the
104 filesystem path under which the server should be installed. If
105 <em>PREFIX</em> is not specified, it defaults to
106 <code>/usr/local/apache2</code>.</p>
108 <p>Each section of the compilation and installation process is
109 described in more detail below, beginning with the requirements
110 for compiling and installing Apache HTTPD.</p>
113 <section id="requirements"><title>Requirements</title>
115 <p>The following requirements exist for building Apache:</p>
119 <dd>Make sure you have at least 50 MB of temporary free disk
120 space available. After installation Apache occupies
121 approximately 10 MB of disk space. The actual disk space
122 requirements will vary considerably based on your chosen
123 configuration options and any third-party modules.</dd>
125 <dt>ANSI-C Compiler and Build System</dt>
126 <dd>Make sure you have an ANSI-C compiler installed. The <a
127 href="http://www.gnu.org/software/gcc/gcc.html">GNU C
128 compiler (GCC)</a> from the <a
129 href="http://www.gnu.org/">Free Software Foundation (FSF)</a>
130 is recommended (version 2.7.2 is fine). If you don't have GCC
131 then at least make sure your vendor's compiler is ANSI
132 compliant. In addition, your <code>PATH</code> must contain
133 basic build tools such as <code>make</code>.</dd>
135 <dt>Accurate time keeping</dt>
136 <dd>Elements of the HTTP protocol are expressed as the time of
137 day. So, it's time to investigate setting some time
138 synchronization facility on your system. Usually the
139 <code>ntpdate</code> or <code>xntpd</code> programs are used for
140 this purpose which are based on the Network Time Protocol (NTP).
141 See the Usenet newsgroup <a
142 href="news:comp.protocols.time.ntp">comp.protocols.time.ntp</a>
143 and the <a href="http://www.ntp.org">NTP
144 homepage</a> for more details about NTP software and public
147 <dt><a href="http://www.perl.org/">Perl 5</a>
149 <dd>For some of the support scripts like <a
150 href="programs/apxs.html">apxs</a> or <a
151 href="programs/dbmmanage.html">dbmmanage</a> (which are
152 written in Perl) the Perl 5 interpreter is required (versions
153 5.003 or newer are sufficient). If no such interpreter is found by
154 the `<code>configure</code>' script there is no harm. Of course, you
155 still can build and install Apache 2.0. Only those support scripts
156 cannot be used. If you have multiple Perl interpreters
157 installed (perhaps a Perl 4 from the vendor and a Perl 5 from
158 your own), then it is recommended to use the <code>--with-perl</code>
159 option (see below) to make sure the correct one is selected
160 by <code>./configure</code>.</dd>
164 <section id="download"><title>Download</title>
166 <p>Apache can be downloaded from the <a
167 href="http://httpd.apache.org/download.cgi">Apache HTTP Server
168 download site</a> which lists several mirrors. You'll find here
169 the latest stable release.</p>
171 <p>After downloading, especially if a mirror site is used, it
172 is important to verify that you have a complete and unmodified
173 version of the Apache HTTP Server. This can be accomplished by
174 testing the downloaded tarball against the PGP signature. This,
175 in turn, is a two step procedure. First, you must obtain the
176 <a href="http://www.apache.org/dist/httpd/KEYS"><code>KEYS</code></a>
177 file from the Apache distribution site, too. (To assure that the
178 <code>KEYS</code> file itself has not been modified, it may be a good
179 idea to use a file from a previous distribution of Apache or import
180 the keys from a public key server.) The keys are imported into
181 your personal key ring using one of the following commands (depending
182 on your pgp version):</p>
184 <example>$ pgp < KEYS</example>
188 <example>$ gpg --import KEYS</example>
190 <p>The next step is to test the tarball against the PGP
191 signature, which should always be obtained from the <a
192 href="http://httpd.apache.org/download.cgi">main Apache
193 website</a>. A link to the signature file is placed behind the
194 corresponding download link or may be found in the particular
195 directory at the <a href="http://www.apache.org/dist/httpd/">Apache
196 distribution site</a>. Its filename is identical to the source
197 tarball with the addition of <code>.asc</code>. Then you can check
198 the distribution with one of the following commands (again,
199 depending on your pgp version):</p>
201 <example>$ pgp httpd-2_1_<em>NN</em>.tar.gz.asc</example>
205 <example>$ gpg --verify httpd-2_1_<em>NN</em>.tar.gz.asc</example>
207 <p>You should receive a message like</p>
209 <example>Good signature from user "Martin Kraemer
210 <martin@apache.org>".</example>
212 <p>Depending on the trust relationships contained in your key
213 ring, you may also receive a message saying that the
214 relationship between the key and the signer of the key cannot
215 be verified. This is not a problem if you trust the
216 authenticity of the <code>KEYS</code> file.</p>
220 <section id="extract"><title>Extract</title>
222 <p>Extracting the source from the Apache HTTPD tarball is a
223 simple matter of uncompressing, and then untarring:</p>
226 $ gzip -d httpd-2_1_<em>NN</em>.tar.gz<br />
227 $ tar xvf httpd-2_1_<em>NN</em>.tar
230 <p>This will create a new directory under the current directory
231 containing the source code for the distribution. You should
232 <code>cd</code> into that directory before proceeding with
233 compiling the server.</p>
236 <section id="configure"><title>Configuring the source tree</title>
238 <p>The next step is to configure the Apache source tree for
239 your particular platform and personal requirements. This is
240 done using the script <code>configure</code> included in the
241 root directory of the distribution. (Developers downloading the
242 CVS version of the Apache source tree will need to have
243 <code>autoconf</code> and <code>libtool</code> installed and
244 will need to run <code>buildconf</code> before proceeding with
245 the next steps. This is not necessary for official
248 <p>To configure the source tree using all the default options,
249 simply type <code>./configure</code>. To change the default
250 options, <code>configure</code> accepts a variety of variables
251 and command line options. Environment variables are generally
252 placed before the <code>./configure</code> command, while other
253 options are placed after. The most important option here is the
254 location prefix where Apache is to be installed later, because
255 Apache has to be configured for this location to work
256 correctly. But there are a lot of other options available for
259 <p>For a short impression of what possibilities you have, here
260 is a typical example which compiles Apache for the installation
261 tree <code>/sw/pkg/apache</code> with a particular compiler and flags
262 plus the two additional modules <module>mod_rewrite</module> and
263 <module>mod_speling</module> for
264 later loading through the DSO mechanism:</p>
267 $ CC="pgcc" CFLAGS="-O2" \<br />
268 ./configure --prefix=/sw/pkg/apache \<br />
269 --enable-rewrite=shared \<br />
270 --enable-speling=shared
273 <p>When <code>configure</code> is run it will take several minutes to
274 test for the availability of features on your system and build
275 Makefiles which will later be used to compile the server.</p>
277 <p>The easiest way to find all of the configuration flags for
278 Apache is to run <code>./configure --help</code>. What follows is a
279 brief description of most of the arguments and environment
282 <section id="environment"><title>Environment Variables</title>
284 <p>The <code>autoconf</code> build process uses several environment
285 variables to configure the build environment. In general, these
286 variables change the method used to build Apache, but not the
287 eventual features of the server. These variables can be placed
288 in the environment before invoking <code>configure</code>, but
289 it is usually easier to specify them on the
290 <code>configure</code> command line as demonstrated in the
294 <dt><code>CC=...</code></dt>
296 <dd>The name of the C compiler command.</dd>
298 <dt><code>CPPFLAGS=...</code></dt>
300 <dd>Miscellaneous C preprocessor and compiler options.</dd>
302 <dt><code>CFLAGS=...</code></dt>
304 <dd>Debugging and optimization options for the C
307 <dt><code>LDFLAGS=...</code></dt>
309 <dd>Miscellaneous options to be passed to the linker.</dd>
311 <dt><code>LIBS=...</code></dt>
313 <dd>Library location information ("<code>-L</code>" and
314 "<code>-l</code>" options) to pass to the linker.</dd>
316 <dt><code>INCLUDES=...</code></dt>
318 <dd>Header file search directories ("<code>-I<em>dir</em></code>").</dd>
320 <dt><code>TARGET=...</code> [Default: <code>httpd</code>]</dt>
322 <dd>Name of the executable which will be built.</dd>
324 <dt><code>NOTEST_CPPFLAGS=...</code></dt>
326 <dt><code>NOTEST_CFLAGS=...</code></dt>
328 <dt><code>NOTEST_LDFLAGS=...</code></dt>
330 <dt><code>NOTEST_LIBS=...</code></dt>
332 <dd>These variables share the same function as their
333 non-<code>NOTEST</code> namesakes. However, the variables are
334 applied to the build process only after autoconf has performed its
335 feature testing. This allows the inclusion of flags which
336 will cause problems during feature testing, but must be used
337 for the final compilation.</dd>
339 <dt><code>SHLIB_PATH=...</code></dt>
341 <dd>Options which specify shared library paths for the
342 compiler and linker.</dd>
346 <section id="output"><title>autoconf Output Options</title>
349 <dt><code>--help</code></dt>
351 <dd>Prints the usage message including all available options,
352 but does not actually configure anything.</dd>
354 <dt><code>--quiet</code></dt>
356 <dd>Prevents the printing of the usual "<code>checking...</code>"
359 <dt><code>--verbose</code></dt>
361 <dd>Prints much more information during the configuration
362 process, including the names of all the files examined.</dd>
366 <section id="pathnames"><title>Pathnames</title>
368 <p>There are currently two ways to configure the pathnames
369 under which Apache will install its files. First, you can
370 specify a directory and have Apache install itself under that
371 directory in its default locations.</p>
374 <dt><code>--prefix=<em>PREFIX</em></code> [Default:
375 <code>/usr/local/apache2</code>]</dt>
377 <dd>Specifies the directory under which the Apache files will
381 <p>It is possible to specify that architecture-dependent files
382 should be placed under a different directory.</p>
385 <dt><code>--exec-prefix=<em>EPREFIX</em></code> [Default:
386 <code><em>PREFIX</em></code>]</dt>
388 <dd>Specifies the directory under which
389 architecture-dependent files will be placed.</dd>
392 <p>The second, and more flexible way to configure the install
393 path locations for Apache is using the
394 <code>config.layout</code> file. Using this method, it is
395 possible to separately specify the location for each type of
396 file within the Apache installation. The
397 <code>config.layout</code> file contains several example
398 configurations, and you can also create your own custom
399 configuration following the examples. The different layouts in
400 this file are grouped into <code><Layout
401 FOO>...</Layout></code> sections and referred to by
402 name as in <code>FOO</code>.</p>
405 <dt><code>--enable-layout=<em>LAYOUT</em></code></dt>
407 <dd>Use the named layout in the <code>config.layout</code>
408 file to specify the installation paths.</dd>
413 <section id="modules"><title>Modules</title>
415 <p>Apache is a modular server. Only the most basic
416 functionality is included in the core server. Extended features
417 are available in various modules. During the configuration
418 process, you must select which modules to compile for use with
419 your server. You can view a <a
420 href="mod/">list of modules</a> included in
421 the documentation. Those modules with a <a
422 href="mod/module-dict.html#Status">status</a> of "Base" are
423 included by default and must be specifically disabled if you do
424 not want them (e.g. <module>mod_userdir</module>). Modules with any
425 other status must be specifically enabled if you wish to use them
426 (e.g. <module>mod_expires</module>).</p>
428 <p>There are two ways for a module to be compiled and used with
429 Apache. Modules may be <em>statically compiled</em>, which
430 means that they are permanently included in the Apache binary.
431 Alternatively, if your operating system supports Dynamic Shared
432 Objects (DSOs) and <code>autoconf</code> can detect that support, then
433 modules may be <em>dynamically compiled</em>. DSO modules are
434 stored separately from the Apache binary, and may be included
435 or excluded from the server using the run-time configuration
436 directives provided by <module>mod_so</module>.
437 The mod_so is automatically included in the server if any
438 dynamic modules are included in the compilation. If you would
439 like to make your server capable of loading DSOs without
440 actually compiling any dynamic modules, you can explicitly
441 <code>--enable-so</code>.</p>
444 <dt><code>--enable-<em>MODULE</em>[=shared]</code></dt>
446 <dd>Compile and include the module <em>MODULE</em>. The
447 identifier <em>MODULE</em> is the <a
448 href="mod/module-dict.html#ModuleIdentifier">Module
449 Identifier</a> from the module documentation without the
450 "_module" string. To compile the module as a DSO, add the
451 option <code>=shared</code>.</dd>
453 <dt><code>--disable-<em>MODULE</em></code></dt>
455 <dd>Remove the module <em>MODULE</em> which would otherwise
456 be compiled and included.</dd>
458 <dt><code>--enable-modules=<em>MODULE-LIST</em></code></dt>
460 <dd>Compile and include the modules listed in the
461 space-separated <em>MODULE-LIST</em>.</dd>
464 <code>--enable-mods-shared=<em>MODULE-LIST</em></code></dt>
466 <dd>Compile and include the modules in the space-separated
467 <em>MODULE-LIST</em> as dynamically loadable (DSO)
471 <p>The <em>MODULE-LIST</em> in the
472 <code>--enable-modules</code> and
473 <code>--enable-mods-shared</code> options is usually a
474 space-separated list of module identifiers. For example, to
475 enable <module>mod_dav</module> and <module>mod_info</module>,
476 you can either use</p>
478 <example>./configure --enable-dav --enable-info</example>
480 <p>or, equivalently,</p>
482 <example>./configure --enable-modules="dav info"</example>
484 <p>In addition, the special keywords <code>all</code> or
485 <code>most</code> can be used to add all or most of the modules
486 in one step. You can then remove any modules that you do not
487 want with the <code>--disable-<em>MODULE</em></code> option.
488 For example, to include all modules as DSOs with the exception
489 of <module>mod_info</module>, you can use</p>
492 ./configure --enable-mods-shared=all
496 <p>In addition to the standard set of modules, Apache 2.0 also
497 includes a choice of <a href="mpm.html">Multi-Processing
498 Modules</a> (MPMs). One, and only one MPM must be included in
499 the compilation process. The default MPMs for each platform are
500 listed on the <a href="mpm.html">MPM documentation page</a>,
501 but can be overridden on the <code>configure</code> command
505 <dt><code>--with-mpm=<em>NAME</em></code></dt>
507 <dd>Choose the mpm <em>NAME</em>.</dd>
510 <p>To activate an MPM called <var>mpm_name</var>, you can use</p>
513 ./configure --with-mpm=<var>mpm_name</var>
518 <section id="dbm"><title>DBM</title>
520 <p>Several Apache features, including
521 <module>mod_authn_dbm</module> and <module>mod_rewrite</module>'s
522 DBM <directive module="mod_rewrite">RewriteMap</directive> use
523 simple key/value databases for quick lookups of information. Apache
524 includes SDBM with its source-code, so this database is always
525 available. If you would like to use other database types, the
526 following <code>configure</code> options are available:</p>
529 <dt><code>--with-gdbm[=<em>path</em>]</code></dt>
530 <dt><code>--with-ndbm[=<em>path</em>]</code></dt>
531 <dt><code>--with-berkeley-db[=<em>path</em>]</code></dt>
533 <dd>If no <em>path</em> is specified, Apache will search for the
534 include files and libraries in the usual search paths. An explicit
535 <em>path</em> will cause Apache to look in
536 <em>path</em><code>/lib</code> and
537 <em>path</em><code>/include</code> for the relevant files. Finally,
538 the <em>path</em> may specify specific include and library paths
539 separated by a colon.</dd>
544 <section id="suexec"><title>Suexec</title>
546 <p>Apache includes a support program called <a
547 href="suexec.html">suexec</a> which can be used to isolate user
548 CGI programs. However, if suexec is improperly configured, it
549 can cause serious security problems. Therefore, you should
550 carefully read and consider the <a href="suexec.html">suexec
551 documentation</a> before implementing this feature.</p>
555 <section id="compile"><title>Build</title>
557 <p>Now you can build the various parts which form the Apache
558 package by simply running the command:</p>
560 <example>$ make</example>
562 <p>Please be patient here, since a base configuration takes
563 approximately 3 minutes to compile under a Pentium III/Linux
564 2.2 system, but this will vary widely depending on your
565 hardware and the number of modules which you have enabled.</p>
568 <section id="install"><title>Install</title>
570 <p>Now it's time to install the package under the configured
571 installation <em>PREFIX</em> (see <code>--prefix</code> option
572 above) by running:</p>
574 <example>$ make install</example>
576 <p>If you are upgrading, the installation will not overwrite
577 your configuration files or documents.</p>
580 <section id="customize"><title>Customize</title>
582 <p>Next, you can customize your Apache HTTP server by editing
583 the <a href="configuring.html">configuration files</a> under
584 <code><em>PREFIX</em>/conf/</code>.</p>
586 <example>$ vi <em>PREFIX</em>/conf/httpd.conf</example>
588 <p>Have a look at the Apache manual under <a
589 href="./">docs/manual/</a> or consult <a
590 href="http://httpd.apache.org/docs-2.1/"
591 >http://httpd.apache.org/docs-2.1/</a> for the most recent version of
592 this manual and a complete reference of available <a
593 href="mod/directives.html">configuration directives</a>.</p>
596 <section id="test"><title>Test</title>
598 <p>Now you can <a href="invoking.html">start</a> your Apache
599 HTTP server by immediately running:</p>
601 <example>$ <em>PREFIX</em>/bin/apachectl start</example>
603 <p>and then you should be able to request your first document
604 via URL <code>http://localhost/</code>. The web page you see is located
605 under the <directive module="core">DocumentRoot</directive>
606 which will usually be <code><em>PREFIX</em>/htdocs/</code>.
607 Then <a href="stopping.html">stop</a> the server again by
610 <example>$ <em>PREFIX</em>/bin/apachectl stop</example>
612 <section id="upgrading"><title>Upgrading</title>
614 <p>The first step in upgrading is to read the release announcement
615 and the file <code>CHANGES</code> in the source distribution to
616 find any changes that may affect your site. When changing between
617 major releases (for example, from 1.3 to 2.0 or from 2.0 to 2.2),
618 there will likely be major differences in the compile-time and
619 run-time configuration that will require manual adjustments. All
620 modules will also need to be upgraded to accomodate changes in the
623 <p>Upgrading from one minor version to the next (for example, from
624 2.0.55 to 2.0.57) is easier. The <code>make install</code>
625 process will not overwrite any of your existing documents, log
626 files, or configuration files. In addition, the developers make
627 every effort to avoid incompatible changes in the
628 <code>configure</code> options, run-time configuration, or the
629 module API between minor versions. In most cases you should be able to
630 use an identical <code>configure</code> command line, an identical
631 configuration file, and all of your modules should continue to
632 work. (This is only valid for versions after 2.0.41; earlier
633 versions have incompatible changes.)</p>
635 <p>If you kept the source tree from your last installation,
636 upgrading is even easier. The file <code>config.nice</code> in
637 the root of the old source tree contains the exact
638 <code>configure</code> command line that you used to configure the
639 source tree. Then to upgrade from one version to the next, you
640 need only copy the <code>config.nice</code> file to the source
641 tree of the new version, edit it to make any desired changes, and
645 $ ./config.nice<br />
648 $ <em>PREFIX</em>/bin/apachectl stop<br />
649 $ <em>PREFIX</em>/bin/apachectl start<br />
652 <note type="warning">You should always test any new version in your
653 environment before putting it into production. For example, you
654 can install and run the new version along side the old one by
655 using a different <code>--prefix</code> and a
656 different port (by adjusting the <directive
657 module="mpm_common">Listen</directive> directive) to test for any
658 incompatibilities before doing the final upgrade.</note>