...
Section |
---|
|
Column |
---|
| Unix/Solaris Code Block |
---|
| # Use -k switch to preserve the original archive
$ bzip2 -d[k] httpd-2.2.32.tar.bz2
$ tar -xvf httpd-2.2.32.tar -C /opt/httpd/ |
|
Column |
---|
| Linux Code Block |
---|
| $ tar -xzvf httpd-2.2.32.tar.gz -C /opt/httpd/ |
|
|
2) Compile Apache
Next, we will compile apache.
Warning |
---|
|
Since Apache 2.4, the Apache Portable Runtime and the Perl Compatible Regex modules are no longer packaged with the original source. However, these modules are mandatory for Apache to compile and run. Expand |
---|
title | Click here to see the additonal steps for 2.4 |
---|
| Expand |
---|
title | Click here to find out why you need these libraries ... |
---|
| APR The APR library provides a set of APIs that map to the underlying O/S and emulate functions if they are not available, making Apache platform-agnostic. PCRE The PCRE library provides more powerful and flexible regex expression functionality than other flavours and is used by mod_rewrite, etc.
|
Apache provides the flexibility to point to existing instances of these when compiling. If you do not have these modules you can add them as follows: First, download the module source files: Code Block |
---|
| $ wget http://archive.apache.org/dist/apr/apr-1.6.3.tar.bz2
$ wget http://archive.apache.org/dist/apr/apr-util-1.6.1.tar.bz2
# Apache 2 requires pcre, not pcre2
$ wget --no-check-certificate https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.bz2 |
Extract the source files: Code Block |
---|
| # APR and APR utils can be compiled with Apache out of the box provided they are in the srclib directory
$ tar -x[z]vf apr-1.6.3.tar[.gz] --directory /opt/httpd-2.4.x/srclib/apr
$ tar -x[z]vf apr-util-1.6.1.tar[.gz] -- directory /opt/httpd-2.4.x/srclib/apr-util
# PCRE will not be automatically compiled in the srclib directory, so either manipulate the build script or simply keep it separate.
$ tar -x[z]vf pcre-8.41.tar[.gz] |
If you've placed PCRE in its own folder, you will have to build it first: Code Block |
---|
| $ ./configure --prefix=/opt/pcre --enable-pcre16 --enable-pcre32
$ make
$ make install |
|
|
Code Block |
---|
|
$ cd /opt/httpd
# First we configure the build using the following syntax
# ./configure --prefix=/opt/apache2 --enable-mods-shared=few [--enable-{modname}] [--disable-{modname}] [with-apr=included] [with-pcre=/opt/pcre]
# Here is the most common configuration
./configure --prefix=/opt/apache2 --enable-mods-shared=few --enable-rewrite --enable-headers --enable-ssl --disable-userdir --disable-autoindex --disable-status --disable-env --disable-setenvif --disable-cgi --disable-actions --disable-negotiation --disable-alias --disable-include --disable-filter --disable-version --disable-asis --with-apr=included --with-pcre=/opt/pcre |
Here it is important to understand what each switch is doing and the implications of each.
Configure Command Switch | What does it do? |
---|
--prefix | Sets the output directory for the build i.e. where Apache will reside. This direcory specification will have a direct impact on portability of the 0FS package. Read more in the Portability section. |
--enable-mods-shared | Sets which modules will be compiled as DSOs (shared libraries). Options are "all" | "most" and in 2.4 and higher also "few" | "none" | "reallyall" |
--enable-{module_name} | Enables the module for the build. Shared or static inclusion is determined by the underlying APR as will as the --enable-mods-shared directive. For example, with Apache 2.4, the standard APR supports DSOs, so it would compile the module as shared, unless the --enable-mods-shared is set to "none", which will force it to be compiled as static. |
--disable-{module_name} | Disables the module for the build. The module will not be compiled at all, so you will not even be able to add it dynamically later through Apache configuration without either recompiling Apache in full or compiling the module itself and copying it into the modules directory of the Apahce install |
--with-{module_name}=path|included | Used to specify specific path to find compiled modules if not using the defaults included with source. The included value will force the build to use the one included with Apache source. |