147N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
147N/A<
TITLE>Compiling and Installing Apache</
TITLE>
147N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) --> 147N/A<
H1 ALIGN="CENTER">Compiling and Installing</
H1>
147N/A<
p>This document covers compilation and installation of Apache on Unix
5680N/Aand Unix-like systems only. For compiling and installation on Windows,
5680N/AWindows</
A>. For other platforms, see the <
a 5680N/Ahref="platform/">platform</
a> documentation.</
p>
147N/A<
p>Apache 2.0's configuration and installation environment has changed
147N/Acompletely from Apache 1.3. Apache 1.3 used a custom set of scripts
147N/Ato achieve easy installation. Apache 2.0 now uses libtool and
147N/Aautoconf to create an environment that looks like many other Open
844N/A<
h3>Overview for the impatient</
h3>
3758N/A<
li><
em>PREFIX</
em> is not the string "PREFIX". Instead use the Unix
206N/Afilesystem path under which Apache should be installed. For instance
7292N/A<
li>if you are building from a copy of the Apache CVS repository,
3758N/Arather than a release distribution, then you must use the "buildconf"
806N/Ascript before running configure.</
li>
806N/A<
li>If you are building on FreeBSD, you should add the argument
806N/A--with-mpm=prefork to the configure line. The Apache Group has
806N/Adiscovered that threads do not work well with Apache on FreeBSD. For
147N/Athat reason, we disable threads by default on FreeBSD, and you need to
3758N/Abuild the prefork MPM. If you wish to try to make threads work on
3823N/AFreeBSD, they can be re-enabled by using --enable-threads</
li>
7292N/A<
p>The following requirements exist for building Apache:</
p>
3758N/AMake sure you have approximately 12 MB of
806N/Atemporary free disk space available. After installation Apache
147N/Aoccupies approximately 5 MB of disk space (the actual required disk
147N/Aspace depends on the amount of compiled in third party modules,
147N/A<
li>ANSI-C Compiler<
br><
br>Make sure you have an ANSI-C compiler
147N/Ainstalled. The GNU C compiler (GCC) from the Free Software Foundation
5680N/A(FSF) is recommended (version 2.7.2 is fine). If you don't have GCC
5680N/Athen at least make sure your vendors compiler is ANSI compliant. You
3758N/A<
li>Perl 5 Interpreter [OPTIONAL]<
br><
br> For some of the support
3758N/Ascripts like `apxs' or `dbmmanage' (which are written in Perl) the
3817N/APerl 5 interpreter is required (versions 5.003 and 5.004 are fine). If
3817N/Ano such interpreter is found by the `configure' script this is no
3817N/Aharm. Of course, you still can build and install Apache 2.0. Only
3817N/Athose support scripts cannot be used. If you have multiple Perl
interpreters installed (perhaps a Perl 4 from the vendor and a Perl 5
from your own), then it is recommended to use the --with-perl option
(see below) to make sure the correct one is selected by /
configure.
<
li>Dynamic Shared Object (DSO) support [OPTIONAL]<
br><
br> To provide
maximum flexibility Apache now is able to load modules under runtime
via the DSO mechanism by using the pragmatic
apr_dso_open()/apr_dso_sym() calls. These calls are not available
under all operating systems therefore you cannot use the DSO mechanism
on all platforms. Apache relies on autoconf to detect the ability to
use DSOs, and libtool to determine how to build DSOs. If your platform
is supported by libtool, and we can find DSO system calls, then DSOs
should work out-of-the-box.<
br><
br>
If your system is not on these lists but has the dlopen-style
interface, you either have to provide the appropriate compiler and
linker flags manually or at least make sure a Perl 5 interpreter is
installed from which Apache can guess the options.<
br><
br></
li>
<
p>If you are building from a copy of the CVS repository, rather than
a release distribution, then you will need these additional tools:</
p>
<
li>Libtool 1.3.3<
br><
br> Make sure that you have libtool 1.3.3 or
later installed before trying to configure and build Apache 2.0.
Libtool can be downloaded from the Free Software Foundation (FSF), at
<
li>Autoconf 2.13<
br><
br> Make sure that you have autoconf 2.13 or
later installed before trying to configure and build Apache 2.0.
Autoconf can be downloaded from the Free Software Foundation (FSF), at
<
h3>Configuring the source tree</
h3>
<
p>If you have downloading the Apache 2.0 from the CVS, rather than a
release distribution, then you will need to prepare the source tree
for configuration and compilation. This is done by running:</
p>
<
p>This script ensures that all required programs are installed on the
currently machine, and creates the /
configure script. If you are
using a package downloaded from
apache.org then this step is not
<
p>The next step is to configure the Apache source tree for your
particular platform and personal requirements. The most important
setup here is the location prefix where Apache is to be installed
later, because Apache has to be configured for this location to work
correctly. But there are a lot of other options available for your
<
p>For a short impression of what possibilities you have, here is a
typical example which compiles Apache for the installation tree
/
sw/
pkg/
apache with a particular compiler and flags plus the two
additional modules mod_rewrite and mod_speling for later loading
through the DSO mechanism:</
p>
$ CC="pgcc" CFLAGS="-O2" \<
br>
--enable-rewrite=shared \<
br>
<
p>The easiest way to find all of the configuration flags for Apache
2.0 is to run /
configure --help. What follows is a brief description
of most of the arguments.</
p>
[CPPFLAGS=...] [NOTEST_CPPFLAGS=...]
[CFLAGS=...] [NOTEST_CFLAGS=...]
[CXXFLAGS=...] [NOTEST_CXXFLAGS=...]
[LDFLAGS=...] [NOTEST_LDFLAGS=...]
[LIBS=...] [NOTEST_LIBS=...]
[INCLUDES=...] [SHLIB_PATH=...]
[--quiet] [--prefix=DIR] [--enable-NAME=(shared)]
[--verbose] [--exec-prefix=PREFIX] [--disable-NAME]
[--shadow[=DIR]] [--bindir=EPREFIX] [--with-mpm=NAME]
[--show-layout] [--sbindir=DIR]
[--help] [--libexecdir=DIR]
[--runtimedir=DIR] [--enable-suexec]
[--logfiledir=DIR] [--suexec-caller=UID]
[--proxycachedir=DIR] [--suexec-docroot=DIR]
[--with-layout=[FILE:]ID] [--suexec-logfile=FILE]
[--with-perl=FILE] [--suexec-uidmin=UID]
[--without-support] [--suexec-gidmin=GID]
[--without-confadjust] [--suexec-safepath=PATH]
[--enable-maintainter-mode]
<
p>Use the CC, CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, LIBS, INCLUDES,
SHLIB_PATH and TARGET environment variables to override or expand the
corresponding default entries as determined by configure.</
p>
<
p>Use NOTEST_CPPFLAGS, NOTEST_CFLAGS, NOTEST_CXXFLAGS,
NOTEST_LDFLAGS, and NOTEST_LIBS to add entries that should only be
used during the actual build and compilation of Apache, such as
<
p>Use the --prefix=PREFIX and --exec-prefix=EPREFIX options to
configure Apache to use a particular installation prefix. The default
<
p>Use the --bindir=DIR, --sbindir=DIR, --libexecdir=DIR,
--mandir=DIR, --sysconfdir=DIR, --datadir=DIR, --iconsdir=DIR,
--htdocsdir=DIR, --cgidir=DIR, --includedir=DIR, --localstatedir=DIR,
--runtimedir=DIR, --logfiledir=DIR and --proxycachedir=DIR option to
change the paths for particular subdirectories of the installation
<
p>Note: To reduce the pollution of shared installation locations
(like /
usr/
local/ or /etc) with Apache files to a minimum the string
``/apache'' is automatically appended to 'libexecdir', 'sysconfdir',
'datadir', 'localstatedir' and 'includedir' if (and only if) the
following points apply for each path individually:</
p>
<
li>the path doesn't already contain the word ``apache''</
li>
<
li>the path was not directly customized by the user</
li>
<
p>Keep in mind that per default these paths are derived from 'prefix'
and 'exec-prefix', so usually its only a matter whether these paths
contain ``apache'' or not. Although the defaults were defined with
experience in mind you always should make sure the paths fit your
situation by checking the finally chosen paths via the --layout
<
p>Use the --with-layout=[F:]ID option to select a particular
installation path base-layout. You always _HAVE_ to select a
base-layout. There are currently two layouts pre-defined in the file
config.layout: `Apache' for the classical Apache path layout and `GNU'
for a path layout conforming to the GNU `standards' document. When you
want to use your own custom layout FOO, either add a corresponding
"<Layout FOO>...</Layout>" section to
config.layout and use
<
p>Use the --show-layout option to check the final installation path
layout while fiddling with the options above.</
p>
<
p>Use the --enable-NAME=(shared) and --disable-NAME options to enable
or disable a particular already distributed module from the Apache
<
p>Use the --with-mpm=NAME option to determine which MPM should be
built for your server.</
p>
<
h3>List of Available Modules</
h3>
(+) mod_env .......... Set environment variables for
CGI/
SSI scripts
(+) mod_setenvif ..... Set environment variables based on HTTP headers
(-) mod_unique_id .... Generate unique identifiers for request
(+) mod_mime ......... Content
type/
encoding determination (configured)
(-) mod_mime_magic ... Content
type/
encoding determination (automatic)
(+) mod_negotiation .. Content selection based on the HTTP Accept* headers
(+) mod_alias ........ Simple URL translation and redirection
(-) mod_rewrite ...... Advanced URL translation and redirection
(+) mod_userdir ...... Selection of resource directories by username
(-) mod_speling ...... Correction of misspelled URLs
(+) mod_dir .......... Directory and directory default file handling
(+) mod_autoindex .... Automated directory index file generation
Access Control and Authentication
(+) mod_access ....... Access Control (user, host, network)
(+) mod_auth ......... HTTP Basic Authentication (user, passwd)
(-) mod_auth_dbm ..... HTTP Basic Authentication via Unix NDBM files
(-) mod_auth_db ...... HTTP Basic Authentication via Berkeley-DB files
(-) mod_auth_anon .... HTTP Basic Authentication for Anonymous-style users
(-) mod_digest ....... HTTP Digest Authentication
(-) mod_headers ...... Arbitrary HTTP response headers (configured)
(-) mod_cern_meta .... Arbitrary HTTP response headers (CERN-style files)
(-) mod_expires ...... Expires HTTP responses
(+) mod_asis ......... Raw HTTP responses
(+) mod_include ...... Server Side Includes (SSI) support
(+) mod_cgi .......... Common Gateway Interface (CGI) support
(+) mod_cgid ......... Common Gateway Interface (CGI) support for
(+) mod_actions ...... Map CGI scripts to act as internal `handlers'
Internal Content Handlers
(+) mod_status ....... Content handler for server run-time status
(-) mod_info ......... Content handler for server configuration summary
(+) mod_log_config ... Customizable logging of requests
(-) mod_usertrack .... Logging of user click-trails via HTTP Cookies
(-) mod_dav .......... WebDAV (RFC 2518) support for Apache
(-) mod_dav_fs ....... mod_dav backend to managing filesystem content
(+) mod_imap ......... Server-side Image Map support
(-) mod_proxy ........ Caching Proxy Module (HTTP, HTTPS, FTP)
(-) mod_so ........... Dynamic Shared Object (DSO) bootstrapping
(-) mod_mmap_static .. Caching of frequently served pages via mmap()
(-) mod_example ...... Apache API demonstration (developers only)
mpmt_pthread ..... Multi-process(dynamic) Multi-threaded(static)
prefork .......... Preforking Unix MPM
perchild ......... Multi-process(static) Multi-threaded(dynamic)
Unix MPM, that allows a User per child process
winnt ............ Multi-process(1) Multi-threaded Windows MPM
mpmt_beos ........ Multi-process Multi-threaded Beos MPM
beos ............. Multi-process Multi-threaded Beos MPM
spmt_os2 ......... Single-process Multi-threaded OS/2 MPM
_________________________________________________________________________
(+) = enabled per default [disable with --disable-module]
(-) = disabled per default [enable with --enable-module ]
<
p>Use the --enable-suexec option to enable the suEXEC feature by
building and installing the "suexec" support program.</
p>
<
p><
strong>CAUTION: FOR DETAILS ABOUT THE SUEXEC FEATURE WE HIGHLY
BEFORE USING THE ABOVE OPTIONS.</
strong></
p>
<
p><
strong>USING THE SUEXEC FEATURE PROPERLY CAN REDUCE CONSIDERABLY
THE SECURITY RISKS INVOLVED WITH ALLOWING USERS TO DEVELOP AND RUN
PRIVATE CGI OR SSI PROGRAMS. HOWEVER, IF SUEXEC IS IMPROPERLY
CONFIGURED, IT CAN CAUSE ANY NUMBER OF PROBLEMS AND POSSIBLY CREATE
NEW HOLES IN YOUR COMPUTER'S SECURITY. IF YOU AREN'T FAMILIAR WITH
MANAGING SETUID ROOT PROGRAMS AND THE SECURITY ISSUES THEY PRESENT, WE
HIGHLY RECOMMEND THAT YOU NOT CONSIDER USING SUEXEC AND KEEP AWAY FROM
THESE OPTIONS!</
strong></
p>
<
p>Use the --quiet option to disable all configuration verbose
<
h3>Building the package</
h3>
<
p>Now you can build the various parts which form the Apache package
by simply running the command:</
p>
<
p>Please be patient here, this takes approximately 2 minutes to
amount of modules you have enabled.</
p>
<
h3>Installing the package</
h3>
<
p>Now its time to install the package under the configured
installation PREFIX (see --prefix option above) by running:</
h3>
<
p>For the paranoid hackers under us: The above command really
installs under prefix _only_,
i.e. no other stuff from your system is
touched. Even if you upgrade an existing installation your
configuration files in
PREFIX/
conf/ are preserved.</
p>
<
h3>Testing the package</
h3>
<
p>Now you can fire up your Apache HTTP server by immediately running:</
p>
<
p>and then you should be able to request your first document via URL
(when you built and installed Apache as a regular user). Then stop the
server again by running:</
p>
<
h3>Customizing the package</
h3>
<
p>Finally you can customize your Apache HTTP server by editing the
<
p>Have a look at the Apache manual under
docs/
manual/ or
configuration directives.</
p>
<
h3>Preparing the system</
h3>
<
p>Proper operation of a public HTTP server requires at least the
<
li>A correctly working
TCP/
IP layer, since HTTP is implemented on top
of
TCP/
IP. Although modern Unix platforms have good networking layers,
always make sure you have all official vendor patches referring to the
network layer applied.</
li>
<
li>Accurate time keeping, since elements of the HTTP protocol are
expressed as the time of day. So, it's time to investigate setting
some time synchronization facility on your system. Usually the ntpdate
or xntpd programs are used for this purpose which are based on the
Network Time Protocol (NTP). See the Usenet newsgroup
and public time servers.</
li>