]> granicus.if.org Git - apache/blob - docs/manual/install.xml
Help doc writer to spot places where:
[apache] / docs / manual / install.xml
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$ -->
5
6 <!--
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
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
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.
21 -->
22
23 <manualpage metafile="install.xml.meta">
24
25   <title>Compiling and Installing</title>
26
27 <summary>
28
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
33     Windows</a> and <a
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>
37
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
40     projects.</p>
41
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>
45
46 </summary>
47
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>
51
52 <section id="overview"><title>Overview for the
53     impatient</title>
54
55     <dl>
56     <dt>Installing on Fedora/CentOS/Red Hat Enterprise Linux</dt>
57     <dd>
58     <highlight>
59 sudo yum install httpd
60 sudo service httpd start
61     </highlight>
62
63     <note type="warning">Newer releases of these distros use
64     <code>dnf</code> rather than <code>yum</code>. See <a
65     href="https://fedoraproject.org/wiki/Apache_HTTP_Server">the
66     Fedora project's documentation</a> for platform-specific notes.</note>
67     </dd>
68
69     <dt>Installing on Ubuntu/Debian</dt>
70     <dd>
71 <highlight>
72 sudo apt install apache2
73 sudo service apache2 start
74 </highlight>
75
76     <note type="warning">See <a href="https://help.ubuntu.com/lts/serverguide/httpd.html">Ubuntu's documentation</a> for platform-specific notes.</note>
77
78     </dd>
79
80     <dt>Installing from source</dt>
81     <dd>
82     <table>
83       <columnspec><column width=".13"/><column width=".80"/></columnspec>
84       <tr>
85         <td><a href="#download">Download</a></td>
86
87         <td>Download the latest release from <a href="http://httpd.apache.org/download.cgi#apache24">http://httpd.apache.org/download.cgi</a>
88         </td>
89       </tr>
90
91       <tr>
92         <td><a href="#extract">Extract</a></td>
93
94         <td><code>$ gzip -d httpd-<em>NN</em>.tar.gz<br />
95          $ tar xvf httpd-<em>NN</em>.tar<br />
96          $ cd httpd-<em>NN</em></code></td>
97       </tr>
98
99       <tr>
100         <td><a href="#configure">Configure</a></td>
101
102         <td><code>$ ./configure --prefix=<em>PREFIX</em></code>
103         </td>
104       </tr>
105
106       <tr>
107         <td><a href="#compile">Compile</a></td>
108
109         <td><code>$ make</code> </td>
110       </tr>
111
112       <tr>
113         <td><a href="#install">Install</a></td>
114
115         <td><code>$ make install</code> </td>
116       </tr>
117
118       <tr>
119         <td><a href="#customize">Customize</a></td>
120
121         <td><code>$ vi <em>PREFIX</em>/conf/httpd.conf</code> </td>
122       </tr>
123
124       <tr>
125         <td><a href="#test">Test</a></td>
126
127         <td><code>$ <em>PREFIX</em>/bin/apachectl -k start</code>
128         </td>
129       </tr>
130     </table>
131
132         <p><em>NN</em> must be replaced with the current version
133         number, and <em>PREFIX</em> must be replaced with the
134         filesystem path under which the server should be installed. If
135         <em>PREFIX</em> is not specified, it defaults to
136         <code>/usr/local/apache2</code>.</p>
137
138         <p>Each section of the compilation and installation process is
139         described in more detail below, beginning with the requirements
140         for compiling and installing Apache httpd.</p>
141     </dd>
142     </dl>
143
144     <note type="warning">Don't see your favorite platform mentioned
145     here? <a href="http://httpd.apache.org/docs-project/">Come help us
146     improve this doc.</a></note>
147
148 </section>
149
150 <section id="requirements"><title>Requirements</title>
151
152     <p>The following requirements exist for building Apache httpd:</p>
153
154     <dl>
155       <dt>APR and APR-Util</dt>
156       <dd>Make sure you have APR and APR-Util already installed on
157       your system. If you don't, or prefer to not use the system-provided
158       versions, download the latest versions of both APR and APR-Util
159       from <a href="http://apr.apache.org/">Apache APR</a>, unpack
160       them into <code>/httpd_source_tree_root/srclib/apr</code> and /httpd_source_tree_root<code>/srclib/apr-util</code>
161       (be sure the directory names do not have version numbers; for example,
162       the APR distribution must be under /httpd_source_tree_root/srclib/apr/) and use
163       <code>./configure</code>'s <code>--with-included-apr</code>
164       option.  On some platforms, you may have to install the
165       corresponding <code>-dev</code> packages to allow httpd to build
166       against your installed copy of APR and APR-Util.</dd>
167
168       <dt>Perl-Compatible Regular Expressions Library (PCRE)</dt>
169       <dd>This library is required but not longer bundled with httpd.
170       Download the source code from <a href="http://www.pcre.org/">http://www.pcre.org</a>,
171       or install a Port or Package.  If your build system can't find
172       the pcre-config script installed by the PCRE build, point to it
173       using the <code>--with-pcre</code> parameter.  On some platforms,
174       you may have to install the corresponding <code>-dev</code>
175       package to allow httpd to build against your installed copy
176       of PCRE.</dd>
177
178       <dt>Disk Space</dt>
179       <dd>Make sure you have at least 50 MB of temporary free disk
180       space available. After installation the server occupies
181       approximately 10 MB of disk space. The actual disk space
182       requirements will vary considerably based on your chosen
183       configuration options, any third-party modules, and, of course,
184       the size of the web site or sites that you have on the server.</dd>
185
186       <dt>ANSI-C Compiler and Build System</dt>
187       <dd>Make sure you have an ANSI-C compiler installed. The <a
188       href="http://gcc.gnu.org/">GNU C
189       compiler (GCC)</a> from the <a
190       href="http://www.gnu.org/">Free Software Foundation (FSF)</a>
191       is recommended. If you don't have GCC
192       then at least make sure your vendor's compiler is ANSI
193       compliant. In addition, your <code>PATH</code> must contain
194       basic build tools such as <code>make</code>.</dd>
195
196       <dt>Accurate time keeping</dt>
197       <dd>Elements of the HTTP protocol are expressed as the time of
198       day. So, it's time to investigate setting some time
199       synchronization facility on your system. Usually the
200       <code>ntpdate</code> or <code>xntpd</code> programs are used for
201       this purpose which are based on the Network Time Protocol (NTP).
202       See the <a href="http://www.ntp.org">NTP
203       homepage</a> for more details about NTP software and public
204       time servers.</dd>
205
206       <dt><a href="http://www.perl.org/">Perl 5</a>
207       [OPTIONAL]</dt>
208       <dd>For some of the support scripts like <program>
209       apxs</program> or <program>dbmmanage</program> (which are
210       written in Perl) the Perl 5 interpreter is required (versions
211       5.003 or newer are sufficient).  If no Perl 5 interpreter is found by the
212       <program>configure</program> script, you will not be able to use
213       the affected support scripts. Of course, you will still be able to
214       build and use Apache httpd.</dd>
215     </dl>
216 </section>
217
218 <section id="download"><title>Download</title>
219
220     <p>The Apache HTTP Server can be downloaded from the <a
221     href="http://httpd.apache.org/download.cgi">Apache HTTP Server
222     download site</a>, which lists several mirrors.  Most users of
223     Apache on unix-like systems will be better off downloading and
224     compiling a source version.  The build process (described below) is
225     easy, and it allows you to customize your server to suit your needs.
226     In addition, binary releases are often not up to date with the latest
227     source releases.  If you do download a binary, follow the instructions
228     in the <code>INSTALL.bindist</code> file inside the distribution.</p>
229
230     <p>After downloading, it is important to verify that you have a
231     complete and unmodified version of the Apache HTTP Server. This
232     can be accomplished by testing the downloaded tarball against the
233     PGP signature.  Details on how to do this are available on the <a
234     href="http://httpd.apache.org/download.cgi#verify">download
235     page</a> and an extended example is available describing the <a
236     href="http://httpd.apache.org/dev/verification.html">use of
237     PGP</a>.</p>
238
239 </section>
240
241 <section id="extract"><title>Extract</title>
242
243     <p>Extracting the source from the Apache HTTP Server tarball is a
244     simple matter of uncompressing, and then untarring:</p>
245
246 <example>
247 $ gzip -d httpd-<em>NN</em>.tar.gz<br />
248 $ tar xvf httpd-<em>NN</em>.tar
249 </example>
250
251     <p>This will create a new directory under the current directory
252     containing the source code for the distribution. You should
253     <code>cd</code> into that directory before proceeding with
254     compiling the server.</p>
255 </section>
256
257 <section id="configure"><title>Configuring the source tree</title>
258
259     <p>The next step is to configure the Apache source tree for your
260     particular platform and personal requirements. This is done using
261     the script <program>configure</program> included in
262     the root directory of the distribution. (Developers downloading
263     an unreleased version of the Apache source tree will need to have
264     <code>autoconf</code> and <code>libtool</code> installed and will
265     need to run <code>buildconf</code> before proceeding with the next
266     steps. This is not necessary for official releases.)</p>
267
268     <p>To configure the source tree using all the default options,
269     simply type <code>./configure</code>. To change the default
270     options, <program>configure</program> accepts a variety of variables
271     and command line options.</p>
272
273     <p>The most important option is the location <code>--prefix</code>
274     where Apache is to be installed later, because Apache has to be
275     configured for this location to work correctly.  More fine-tuned
276     control of the location of files is possible with additional <a
277     href="programs/configure.html#installationdirectories">configure
278     options</a>.</p>
279
280     <p>Also at this point, you can specify which <a
281     href="programs/configure.html#optionalfeatures">features</a> you
282     want included in Apache by enabling and disabling <a
283     href="mod/">modules</a>.  Apache comes with a wide range of modules
284     included by default.  They will be compiled as
285     <a href="dso.html">shared objects (DSOs)</a> which can be loaded
286     or unloaded at runtime.
287     You can also choose to compile modules statically by using the option
288     <code>--enable-<var>module</var>=static</code>.</p>
289
290     <p>Additional modules are enabled using the
291     <code>--enable-<var>module</var></code> option, where
292     <var>module</var> is the name of the module with the
293     <code>mod_</code> string removed and with any underscore converted
294     to a dash.  Similarly, you can disable modules with the
295     <code>--disable-<var>module</var></code> option.  Be careful when
296     using these options, since <program>configure</program> cannot warn you
297     if the module you specify does not exist; it will simply ignore the
298     option.</p>
299
300     <p>In addition, it is sometimes necessary to provide the
301     <program>configure</program> script with extra information about the
302     location of your compiler, libraries, or header files.  This is
303     done by passing either environment variables or command line
304     options to <program>configure</program>.  For more information, see the
305     <program>configure</program> manual page. Or invoke
306     <program>configure</program> using the <code>--help</code> option.</p>
307
308     <p>For a short impression of what possibilities you have, here
309     is a typical example which compiles Apache for the installation
310     tree <code>/sw/pkg/apache</code> with a particular compiler and flags
311     plus the two additional modules <module>mod_ldap</module> and
312     <module>mod_lua</module>:</p>
313
314 <example>
315       $ CC="pgcc" CFLAGS="-O2" \<br />
316        ./configure --prefix=/sw/pkg/apache \<br />
317        --enable-ldap=shared \<br />
318        --enable-lua=shared
319 </example>
320
321     <p>When <program>configure</program> is run it will take several minutes to
322     test for the availability of features on your system and build
323     Makefiles which will later be used to compile the server.</p>
324
325     <p>Details on all the different <program>configure</program> options are
326     available on the <program>configure</program> manual page.</p>
327 </section>
328
329 <section id="compile"><title>Build</title>
330
331     <p>Now you can build the various parts which form the Apache
332     package by simply running the command:</p>
333
334 <example>$ make</example>
335
336     <p>Please be patient here, since a base configuration takes
337     several minutes to compile and the time will vary widely
338     depending on your hardware and the number of modules that you
339     have enabled.</p>
340 </section>
341
342 <section id="install"><title>Install</title>
343
344     <p>Now it's time to install the package under the configured
345     installation <em>PREFIX</em> (see <code>--prefix</code> option
346     above) by running:</p>
347
348 <example>$ make install</example>
349
350     <p>This step will typically require root privileges, since
351     <em>PREFIX</em> is usually a directory with restricted write
352     permissions.</p>
353
354     <p>If you are upgrading, the installation will not overwrite
355     your configuration files or documents.</p>
356 </section>
357
358 <section id="customize"><title>Customize</title>
359
360     <p>Next, you can customize your Apache HTTP server by editing
361     the <a href="configuring.html">configuration files</a> under
362     <code><em>PREFIX</em>/conf/</code>.</p>
363
364 <example>$ vi <em>PREFIX</em>/conf/httpd.conf</example>
365
366     <p>Have a look at the Apache manual under
367     <code><em>PREFIX</em>/docs/manual/</code> or consult <a
368     href="http://httpd.apache.org/docs/&httpd.docs;/"
369     >http://httpd.apache.org/docs/&httpd.docs;/</a> for the most recent
370     version of this manual and a complete reference of available <a
371     href="mod/directives.html">configuration directives</a>.</p>
372 </section>
373
374 <section id="test"><title>Test</title>
375
376     <p>Now you can <a href="invoking.html">start</a> your Apache
377     HTTP server by immediately running:</p>
378
379 <example>$ <em>PREFIX</em>/bin/apachectl -k start</example>
380
381     <p>You should then be able to request your first document
382     via the URL <code>http://localhost/</code>. The web page you see is located
383     under the <directive module="core">DocumentRoot</directive>,
384     which will usually be <code><em>PREFIX</em>/htdocs/</code>.
385     Then <a href="stopping.html">stop</a> the server again by
386     running:</p>
387
388 <example>$ <em>PREFIX</em>/bin/apachectl -k stop</example>
389 </section>
390 <section id="upgrading"><title>Upgrading</title>
391
392     <p>The first step in upgrading is to read the release announcement
393     and the file <code>CHANGES</code> in the source distribution to
394     find any changes that may affect your site.  When changing between
395     major releases (for example, from 2.0 to 2.2 or from 2.2 to 2.4),
396     there will likely be major differences in the compile-time and
397     run-time configuration that will require manual adjustments.  All
398     modules will also need to be upgraded to accommodate changes in the
399     module API.</p>
400
401     <p>Upgrading from one minor version to the next (for example, from
402     2.2.55 to 2.2.57) is easier.  The <code>make install</code>
403     process will not overwrite any of your existing documents, log
404     files, or configuration files.  In addition, the developers make
405     every effort to avoid incompatible changes in the
406     <program>configure</program> options, run-time configuration, or the
407     module API between minor versions.  In most cases you should be able to
408     use an identical <program>configure</program> command line, an identical
409     configuration file, and all of your modules should continue to
410     work.</p>
411
412     <p>To upgrade across minor versions, start by finding the file
413     <code>config.nice</code> in the <code>build</code> directory of
414     your installed server or at the root of the source tree for your
415     old install.  This will contain the exact
416     <program>configure</program> command line that you used to
417     configure the source tree.  Then to upgrade from one version to
418     the next, you need only copy the <code>config.nice</code> file to
419     the source tree of the new version, edit it to make any desired
420     changes, and then run:</p>
421
422     <example>
423     $ ./config.nice<br />
424     $ make<br />
425     $ make install<br />
426     $ <em>PREFIX</em>/bin/apachectl -k graceful-stop<br />
427     $ <em>PREFIX</em>/bin/apachectl -k start<br />
428     </example>
429
430     <note type="warning">You should always test any new version in your
431     environment before putting it into production.  For example, you
432     can install and run the new version along side the old one by
433     using a different <code>--prefix</code> and a
434     different port (by adjusting the <directive
435     module="mpm_common">Listen</directive> directive) to test for any
436     incompatibilities before doing the final upgrade.</note>
437
438     <p>You can pass additional arguments to <code>config.nice</code>,
439     which will be appended to your original <program>configure</program>
440     options:</p>
441
442     <example>
443     $ ./config.nice --prefix=/home/test/apache --with-port=90
444     </example>
445 </section>
446 <section id="thirdp"><title>Third-party packages</title>
447
448     <p>A large number of third parties provide their own packaged
449     distributions of the Apache HTTP Server for installation on
450     particular platforms. This includes the various Linux distributions,
451     various third-party Windows packages, Mac OS X, Solaris, and many
452     more.</p>
453
454     <p>Our software license not only permits, but encourages, this kind
455     of redistribution. However, it does result in a situation where the
456     configuration layout and defaults on your installation of the server
457     may differ from what is stated in the documentation. While
458     unfortunate, this situation is not likely to change any time
459     soon.</p>
460
461     <p>A <a
462     href="http://wiki.apache.org/httpd/DistrosDefaultLayout">description
463     of these third-party distrubutions</a> is maintained in the HTTP
464     Server wiki, and should reflect the current state of these
465     third-party distributions. However, you will need to familiarize
466     yourself with your particular platform's package management and
467     installation procedures.</p>
468
469 </section>
470 </manualpage>