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 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <manualpage metafile="install.xml.meta">
25 <title>Compiling and Installing</title>
29 <p>This document covers compilation and installation of the Apache HTTP Server
30 on Unix and Unix-like systems only. For compiling and
31 installation on Windows, see <a
32 href="platform/windows.html">Using Apache HTTP Server with Microsoft
34 href="platform/win_compiling.html">Compiling Apache for Microsoft Windows</a>.
35 For other platforms, see the <a
36 href="platform/">platform</a> documentation.</p>
38 <p>Apache httpd uses <code>libtool</code> and <code>autoconf</code>
39 to create a build environment that looks like many other Open Source
42 <p>If you are upgrading from one minor version to the next (for
43 example, 2.4.8 to 2.4.9), please skip down to the <a
44 href="#upgrading">upgrading</a> section.</p>
48 <seealso><a href="programs/configure.html">Configure the source tree</a></seealso>
49 <seealso><a href="invoking.html">Starting Apache httpd</a></seealso>
50 <seealso><a href="stopping.html">Stopping and Restarting</a></seealso>
52 <section id="overview"><title>Overview for the
56 <columnspec><column width=".13"/><column width=".80"/></columnspec>
58 <td><a href="#download">Download</a></td>
60 <td><code>$ lynx http://httpd.apache.org/download.cgi</code>
65 <td><a href="#extract">Extract</a></td>
67 <td><code>$ gzip -d httpd-<em>NN</em>.tar.gz<br />
68 $ tar xvf httpd-<em>NN</em>.tar<br />
69 $ cd httpd-<em>NN</em></code></td>
73 <td><a href="#configure">Configure</a></td>
75 <td><code>$ ./configure --prefix=<em>PREFIX</em></code>
80 <td><a href="#compile">Compile</a></td>
82 <td><code>$ make</code> </td>
86 <td><a href="#install">Install</a></td>
88 <td><code>$ make install</code> </td>
92 <td><a href="#customize">Customize</a></td>
94 <td><code>$ vi <em>PREFIX</em>/conf/httpd.conf</code> </td>
98 <td><a href="#test">Test</a></td>
100 <td><code>$ <em>PREFIX</em>/bin/apachectl -k start</code>
105 <p><em>NN</em> must be replaced with the current version
106 number, and <em>PREFIX</em> must be replaced with the
107 filesystem path under which the server should be installed. If
108 <em>PREFIX</em> is not specified, it defaults to
109 <code>/usr/local/apache2</code>.</p>
111 <p>Each section of the compilation and installation process is
112 described in more detail below, beginning with the requirements
113 for compiling and installing Apache httpd.</p>
116 <section id="requirements"><title>Requirements</title>
118 <p>The following requirements exist for building Apache httpd:</p>
121 <dt>APR and APR-Util</dt>
122 <dd>Make sure you have APR and APR-Util already installed on
123 your system. If you don't, or prefer to not use the system-provided
124 versions, download the latest versions of both APR and APR-Util
125 from <a href="http://apr.apache.org/">Apache APR</a>, unpack
126 them into <code>./srclib/apr</code> and <code>./srclib/apr-util</code>
127 (be sure the directory names do not have version numbers; for example,
128 the APR distribution must be under ./srclib/apr/) and use
129 <code>./configure</code>'s <code>--with-included-apr</code>
130 option. On some platforms, you may have to install the
131 corresponding <code>-dev</code> packages to allow httpd to build
132 against your installed copy of APR and APR-Util.</dd>
134 <dt>Perl-Compatible Regular Expressions Library (PCRE)</dt>
135 <dd>This library is required but not longer bundled with httpd.
136 Download the source code from <a href="http://www.pcre.org/">http://www.pcre.org</a>,
137 or install a Port or Package. If your build system can't find
138 the pcre-config script installed by the PCRE build, point to it
139 using the <code>--with-pcre</code> parameter. On some platforms,
140 you may have to install the corresponding <code>-dev</code>
141 package to allow httpd to build against your installed copy
145 <dd>Make sure you have at least 50 MB of temporary free disk
146 space available. After installation the server occupies
147 approximately 10 MB of disk space. The actual disk space
148 requirements will vary considerably based on your chosen
149 configuration options, any third-party modules, and, of course,
150 the size of the web site or sites that you have on the server.</dd>
152 <dt>ANSI-C Compiler and Build System</dt>
153 <dd>Make sure you have an ANSI-C compiler installed. The <a
154 href="http://gcc.gnu.org/">GNU C
155 compiler (GCC)</a> from the <a
156 href="http://www.gnu.org/">Free Software Foundation (FSF)</a>
157 is recommended. If you don't have GCC
158 then at least make sure your vendor's compiler is ANSI
159 compliant. In addition, your <code>PATH</code> must contain
160 basic build tools such as <code>make</code>.</dd>
162 <dt>Accurate time keeping</dt>
163 <dd>Elements of the HTTP protocol are expressed as the time of
164 day. So, it's time to investigate setting some time
165 synchronization facility on your system. Usually the
166 <code>ntpdate</code> or <code>xntpd</code> programs are used for
167 this purpose which are based on the Network Time Protocol (NTP).
168 See the <a href="http://www.ntp.org">NTP
169 homepage</a> for more details about NTP software and public
172 <dt><a href="http://www.perl.org/">Perl 5</a>
174 <dd>For some of the support scripts like <program>
175 apxs</program> or <program>dbmmanage</program> (which are
176 written in Perl) the Perl 5 interpreter is required (versions
177 5.003 or newer are sufficient). If you have multiple Perl
178 interpreters (for example, a systemwide install of Perl 4, and
179 your own install of Perl 5), you are advised to use the
180 <code>--with-perl</code> option (see below) to make sure the
181 correct one is used by <program>configure</program>.
182 If no Perl 5 interpreter is found by the
183 <program>configure</program> script, you will not be able to use
184 the affected support scripts. Of course, you will still be able to
185 build and use Apache httpd.</dd>
189 <section id="download"><title>Download</title>
191 <p>The Apache HTTP Server can be downloaded from the <a
192 href="http://httpd.apache.org/download.cgi">Apache HTTP Server
193 download site</a>, which lists several mirrors. Most users of
194 Apache on unix-like systems will be better off downloading and
195 compiling a source version. The build process (described below) is
196 easy, and it allows you to customize your server to suit your needs.
197 In addition, binary releases are often not up to date with the latest
198 source releases. If you do download a binary, follow the instructions
199 in the <code>INSTALL.bindist</code> file inside the distribution.</p>
201 <p>After downloading, it is important to verify that you have a
202 complete and unmodified version of the Apache HTTP Server. This
203 can be accomplished by testing the downloaded tarball against the
204 PGP signature. Details on how to do this are available on the <a
205 href="http://httpd.apache.org/download.cgi#verify">download
206 page</a> and an extended example is available describing the <a
207 href="http://httpd.apache.org/dev/verification.html">use of
212 <section id="extract"><title>Extract</title>
214 <p>Extracting the source from the Apache HTTP Server tarball is a
215 simple matter of uncompressing, and then untarring:</p>
218 $ gzip -d httpd-<em>NN</em>.tar.gz<br />
219 $ tar xvf httpd-<em>NN</em>.tar
222 <p>This will create a new directory under the current directory
223 containing the source code for the distribution. You should
224 <code>cd</code> into that directory before proceeding with
225 compiling the server.</p>
228 <section id="configure"><title>Configuring the source tree</title>
230 <p>The next step is to configure the Apache source tree for your
231 particular platform and personal requirements. This is done using
232 the script <program>configure</program> included in
233 the root directory of the distribution. (Developers downloading
234 an unreleased version of the Apache source tree will need to have
235 <code>autoconf</code> and <code>libtool</code> installed and will
236 need to run <code>buildconf</code> before proceeding with the next
237 steps. This is not necessary for official releases.)</p>
239 <p>To configure the source tree using all the default options,
240 simply type <code>./configure</code>. To change the default
241 options, <program>configure</program> accepts a variety of variables
242 and command line options.</p>
244 <p>The most important option is the location <code>--prefix</code>
245 where Apache is to be installed later, because Apache has to be
246 configured for this location to work correctly. More fine-tuned
247 control of the location of files is possible with additional <a
248 href="programs/configure.html#installationdirectories">configure
251 <p>Also at this point, you can specify which <a
252 href="programs/configure.html#optionalfeatures">features</a> you
253 want included in Apache by enabling and disabling <a
254 href="mod/">modules</a>. Apache comes with a wide range of modules
255 included by default. They will be compiled as
256 <a href="dso.html">shared objects (DSOs)</a> which can be loaded
257 or unloaded at runtime.
258 You can also choose to compile modules statically by using the option
259 <code>--enable-<var>module</var>=static</code>.</p>
261 <p>Additional modules are enabled using the
262 <code>--enable-<var>module</var></code> option, where
263 <var>module</var> is the name of the module with the
264 <code>mod_</code> string removed and with any underscore converted
265 to a dash. Similarly, you can disable modules with the
266 <code>--disable-<var>module</var></code> option. Be careful when
267 using these options, since <program>configure</program> cannot warn you
268 if the module you specify does not exist; it will simply ignore the
271 <p>In addition, it is sometimes necessary to provide the
272 <program>configure</program> script with extra information about the
273 location of your compiler, libraries, or header files. This is
274 done by passing either environment variables or command line
275 options to <program>configure</program>. For more information, see the
276 <program>configure</program> manual page. Or invoke
277 <program>configure</program> using the <code>--help</code> option.</p>
279 <p>For a short impression of what possibilities you have, here
280 is a typical example which compiles Apache for the installation
281 tree <code>/sw/pkg/apache</code> with a particular compiler and flags
282 plus the two additional modules <module>mod_ldap</module> and
283 <module>mod_lua</module>:</p>
286 $ CC="pgcc" CFLAGS="-O2" \<br />
287 ./configure --prefix=/sw/pkg/apache \<br />
288 --enable-ldap=shared \<br />
292 <p>When <program>configure</program> is run it will take several minutes to
293 test for the availability of features on your system and build
294 Makefiles which will later be used to compile the server.</p>
296 <p>Details on all the different <program>configure</program> options are
297 available on the <program>configure</program> manual page.</p>
300 <section id="compile"><title>Build</title>
302 <p>Now you can build the various parts which form the Apache
303 package by simply running the command:</p>
305 <example>$ make</example>
307 <p>Please be patient here, since a base configuration takes
308 several minutes to compile and the time will vary widely
309 depending on your hardware and the number of modules that you
313 <section id="install"><title>Install</title>
315 <p>Now it's time to install the package under the configured
316 installation <em>PREFIX</em> (see <code>--prefix</code> option
317 above) by running:</p>
319 <example>$ make install</example>
321 <p>This step will typically require root privileges, since
322 <em>PREFIX</em> is usually a directory with restricted write
325 <p>If you are upgrading, the installation will not overwrite
326 your configuration files or documents.</p>
329 <section id="customize"><title>Customize</title>
331 <p>Next, you can customize your Apache HTTP server by editing
332 the <a href="configuring.html">configuration files</a> under
333 <code><em>PREFIX</em>/conf/</code>.</p>
335 <example>$ vi <em>PREFIX</em>/conf/httpd.conf</example>
337 <p>Have a look at the Apache manual under
338 <code><em>PREFIX</em>/docs/manual/</code> or consult <a
339 href="http://httpd.apache.org/docs/&httpd.docs;/"
340 >http://httpd.apache.org/docs/&httpd.docs;/</a> for the most recent
341 version of this manual and a complete reference of available <a
342 href="mod/directives.html">configuration directives</a>.</p>
345 <section id="test"><title>Test</title>
347 <p>Now you can <a href="invoking.html">start</a> your Apache
348 HTTP server by immediately running:</p>
350 <example>$ <em>PREFIX</em>/bin/apachectl -k start</example>
352 <p>You should then be able to request your first document
353 via the URL <code>http://localhost/</code>. The web page you see is located
354 under the <directive module="core">DocumentRoot</directive>,
355 which will usually be <code><em>PREFIX</em>/htdocs/</code>.
356 Then <a href="stopping.html">stop</a> the server again by
359 <example>$ <em>PREFIX</em>/bin/apachectl -k stop</example>
361 <section id="upgrading"><title>Upgrading</title>
363 <p>The first step in upgrading is to read the release announcement
364 and the file <code>CHANGES</code> in the source distribution to
365 find any changes that may affect your site. When changing between
366 major releases (for example, from 2.0 to 2.2 or from 2.2 to 2.4),
367 there will likely be major differences in the compile-time and
368 run-time configuration that will require manual adjustments. All
369 modules will also need to be upgraded to accommodate changes in the
372 <p>Upgrading from one minor version to the next (for example, from
373 2.2.55 to 2.2.57) is easier. The <code>make install</code>
374 process will not overwrite any of your existing documents, log
375 files, or configuration files. In addition, the developers make
376 every effort to avoid incompatible changes in the
377 <program>configure</program> options, run-time configuration, or the
378 module API between minor versions. In most cases you should be able to
379 use an identical <program>configure</program> command line, an identical
380 configuration file, and all of your modules should continue to
383 <p>To upgrade across minor versions, start by finding the file
384 <code>config.nice</code> in the <code>build</code> directory of
385 your installed server or at the root of the source tree for your
386 old install. This will contain the exact
387 <program>configure</program> command line that you used to
388 configure the source tree. Then to upgrade from one version to
389 the next, you need only copy the <code>config.nice</code> file to
390 the source tree of the new version, edit it to make any desired
391 changes, and then run:</p>
394 $ ./config.nice<br />
397 $ <em>PREFIX</em>/bin/apachectl -k graceful-stop<br />
398 $ <em>PREFIX</em>/bin/apachectl -k start<br />
401 <note type="warning">You should always test any new version in your
402 environment before putting it into production. For example, you
403 can install and run the new version along side the old one by
404 using a different <code>--prefix</code> and a
405 different port (by adjusting the <directive
406 module="mpm_common">Listen</directive> directive) to test for any
407 incompatibilities before doing the final upgrade.</note>
409 <p>You can pass additional arguments to <code>config.nice</code>,
410 which will be appended to your original <program>configure</program>
414 $ ./config.nice --prefix=/home/test/apache --with-port=90
417 <section id="thirdp"><title>Third-party packages</title>
419 <p>A large number of third parties provide their own packaged
420 distributions of the Apache HTTP Server for installation on
421 particular platforms. This includes the various Linux distributions,
422 various third-party Windows packages, Mac OS X, Solaris, and many
425 <p>Our software license not only permits, but encourages, this kind
426 of redistribution. However, it does result in a situation where the
427 configuration layout and defaults on your installation of the server
428 may differ from what is stated in the documentation. While
429 unfortunate, this situation is not likely to change any time
433 href="http://wiki.apache.org/httpd/DistrosDefaultLayout">description
434 of these third-party distrubutions</a> is maintained in the HTTP
435 Server wiki, and should reflect the current state of these
436 third-party distributions. However, you will need to familiarize
437 yourself with your particular platform's package management and
438 installation procedures.</p>