Home arrow Apache arrow Page 7 - Building Apache the Way You Want It

Advanced Configuration - Apache

Have you ever wanted to customize Apache? This article will help you get started on building a customized version of Apache to suit your own needs. It is taken from chapter three of the book Pro Apache third edition, written by Peter Wainwright (Apress, 2004; ISBN: 1590593006).

TABLE OF CONTENTS:
  1. Building Apache the Way You Want It
  2. Building Apache from Source
  3. General Options
  4. Enabling or Disabling Modules in Bulk
  5. Changing the Module Order (Apache 1.3)
  6. Building Apache from Source As an RPM (Apache 2)
  7. Advanced Configuration
  8. Determining Apacheís Locations Individually
  9. Choosing a MultiProcessing Module (Apache 2)
  10. Building Apache with suExec support
  11. Configuring Apache 2 for Cross-Platform Builds
  12. Configuring the Build Environment
  13. Building Modules with apxs
By: Apress Publishing
Rating: starstarstarstarstar / 14
August 18, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The configuration options youíve considered so far are enough for many purposes, and certainly sufficient for setting up a test server. However, there are many more advanced options at your disposal, ranging from the useful to the curious to the downright obscure. This is especially true of Apache 2, which provides many autoconf-derived options that, although available, arenít actually that useful in Apache.

Of these options, the most immediately useful are the layout options that determine both where Apacheís files are installed and where Apache expects to find them by default. Other advanced features include the build type for cross-platform builds, platform-specific rules, and locating external packages required by some of Apacheís own features.

Configuring Apacheís Layout

Youíve already seen how --prefix defines the installation root for Apache. However, configure allows several more options to customize the location of Apacheís files in detail.

Choosing a Layout Scheme

The default layout for Apache consists of an installation path in /usr/local/apache, with the various other directories placed underneath. However, itís possible to completely configure the entire layout. To make life simple, the configure script accepts a named layout defined in a file called config.layout thatís supplied with the Apache source distribution. This contains many alternative layouts that can be chosen by specifying their name on the configure command line:

[1.3] $ ./configure --with-layout=Apache
[2.0] $ ./configure --enable-layout=Apache

This tells configure to use the Apache layout (this is in fact the default), which causes it to select the Apache layout record in config.layout:

# Classical Apache path layout.
<Layout Apache>
 
prefix:        /usr/local/apache
 
exec_prefix:   $prefix
 
bindir:        $exec_prefix/bin
 
sbindir:       $exec_prefix/bin
 
libexecdir:    $exec_prefix/modules
 
mandir:        $prefix/man
 
sysconfdir:    $prefix/conf
 
datadir:       $prefix
 
installbuilddir: $datadir/build
 
errordir:      $datadir/error
  iconsdir:      $datadir/icons
  htdocsdir:     $datadir/htdocs
  manualdir:     $datadir/manual
  cgidir:        $datadir/cgi-bin
  includedir:    $prefix/include
  localstatedir: $prefix
 
runtimedir:    $localstatedir/logs
 
logfiledir:    $localstatedir/logs
 
proxycachedir: $localstatedir/proxy
</Layout>

From this itís clear which values control which locations and how the various values depend on each other; the installbuilddir and errordir locations are new to Apache 2, but otherwise the locations understood by the two versions are identical. The default layout in Apache 1.3 differs from the previous Apache 2 layout only in the name of the libexec directory; itís $exec_prefix/libexec in Apache 1.3.

There are ten other layouts defined in config.layout. Note that case is important and that GNU is a valid parameter, but gnu or Gnu arenít. Table 3-4 details the available layouts along with their main installation prefix (though many of them adjust specific locations in addition).

Table 3-4. Layout Choices

Layout

Description

GNU

Installs files directly into subdirectories of /usr/local rather than in a separate /usr/local/apache directory. The httpd binary thus goes in /usr/local/bin and the manual pages in /usr/local/man.

MacOS X Server

Installation paths for MacOS X Server (a.k.a. Rhapsody) operating system (prefix /Local/Library/WebServer).

Darwin

Installation paths for MacOS X (a.k.a. Darwin). This is the consumer version found on desktop machines, as opposed to the server edition, and has a significantly different layout (prefix /usr).

RedHat

Installs files in the default locations for RedHat Linux. This is typically used in the construction of RPM packages for RedHat and is also suitable for RedHat-based distributions such as Mandrake Linux (prefix /usr).

beos

Installation paths for the BeOS operating system (prefix /boot/home/ apache).

SuSE

Installs files in the default locations for SuSE Linux. This is typically used in the construction of RPM packages for SuSE and is also suitable for UnitedLinux distributions (prefix /usr).

OpenBSD

Installs files in the default locations for OpenBSD (prefix /var/www).

BSDI

Installs files in the default locations for BSDIís commercial BSD variant

(prefix /var/www).

Solaris

Installs files in the default locations for Solaris (prefix /usr/apache).

The Binary Distribution Layout

In addition to the standard layouts previously, thereís also one special layout, BinaryDistribution. This is provided to build Apache for packaging and distribution. The distribution may then be unpacked and installed on the target machine or machines, with the installation root chosen at the time of installation. All other locations are defined as relative directories. This allows you to create an archive containing your own complete custom Apache. You can then unpack and install it into the correct location on multiple machines.

Because the creation of a binary distribution is more involved than a straightforward build and install, Apache 2 provides the binbuild.sh and install-bindist.sh scripts, located in the build directory under the top source distribution directory, to help you do it. To use binbuild.sh, you first need to edit it and modify the configure options defined in CONFIGPARAM to build the Apache server you want (donít change the layout from BinaryDistribution). Then run the following from the top directory of the source distribution:

$ ./build/binbuild.sh

This will configure and build Apache as a binary distribution and then package it into an archive named for the Apache version and target host. For example, on a Pentium III Linux server, the resulting archive would be called as so:

httpd-2.0.46-i786-pc-linux.tar.gz

You also get a readme file explaining how the archive was built:

httpd-2.0.46-i786-pc-linux.README

These files appear next to the unpacked source distributionóthat is, the directory above where you actually ran binbuild.sh. You can now transfer and unpack the archive onto any Linux server on which you want to install Apache. After unpacking it, you use the install-bindist.sh script. This takes one argument, the server root where Apache is to be installed, for example:

$ ./install-bindist.sh /usr/local/apache_dist

You can also run this script directly from the source directory where you ran binbuild.sh if you want to install the distribution on the same host.

This will copy and set up the Apache distribution so that itís configured to run from the specified directory. Once this is done, you can dispense with the original unpacked archive. The default server root, if you donít specify one, is /usr/local/apache2; this can be changed by editing DEFAULT_DIR at the same time as CONFIGPARAM before you run binbuild.sh. Note that install-bindist.sh is itself generated by binbuild.sh and doesnít exist except in the build directory of the archives generated by it.

Another file thatís generated by binbuild.sh is the envvars file located adjacent to apachectl in the selected location for executables. apachectl reads envvars to determine the correct environment to start Apache with. For a binary distribution, this typically involves adding additional shared library paths to LD_LIBRARY_PATH (or a similar variable, depending on the platform) so that Apache can find dynamic modules. This is a necessary step because Apacheís installation directories werenít known at the time you built it for distribution. For a normal undistributed installation, this file contains no active definitions. An original unmodified version of this file is also provided as envvars-std, for reference, if you change envvars.

Adding and Customizing Layouts

Itís also possible to add your own custom layouts to the file by adding a new definition with the name of your layout, for example:

# My custom Apache layout
<Layout AlphaComplex>
  ... locations ...
</Layout>

Although itís not used in the default Apache layout, you can also use the special suffix + on locations to indicate that the name of the server (as defined by --target or --with-program name in Apache 1.3 and 2, respectively) should be added to the end of the path. For example, in the Darwin layout, you find this definition for the log directory:

logfiledir: ${localstatedir}/log+

As localstatedir is set to /var in the Darwin layout, this means that (with a program name of osxhttpd) Apacheís log files will, in this layout scheme, be located here:

/var/log/osxhttpd

If you donít want to edit the supplied layout.conf file, you can instead use your own file by prefixing the filename to the layout name:

[1.3] $ ./configure --with-layout=mylayout.conf:bespoke
[2.0] $ ./configure --enable-layout=mylayout.conf:bespoke

You can also specify a layout file outside the Apache source distribution if you want. This makes it easy to maintain a local configuration and build successive Apache releases with it.

The alternative to defining your own layout is to specify each of the layout paths on the command line with individual options. The approach you choose depends for the most part on how many locations you want to change.

You can check the effect of a layout scheme with the --show-layout option. This causes the configure script to return a list of the configured directories and defaults instead of actually processing them, for example (using an Apache 1.3 source distribution):

[1.3] $ ./configure --target=osxhttpd --with-layout=Darwin --show-layout

This produces the following output:

Configuring for Apache, Version 1.3.28
+ using installation path layout: Darwin (config.layout)Installation paths:
              prefix: /usr
         exec_prefix: /usr
              bindir: /usr/bin
             sbindir: /usr/sbin 
          libexecdir: /usr/libexec/osxhttpd
              mandir: /usr/share/man
          sysconfdir: /etc/osxhttpd              
             datadir: /Library/WebServer
 
            iconsdir: /usr/share/httpd/icons 
           htdocsdir: /Library/WebServer/Documents 
           manualdir: /Library/WebServer/Documents/manual
              cgidir: /Library/WebServer/CGI-Executables  
          includedir: /usr/include/osxhttpd
      
localstatedir: /var
          runtimedir: /var/run 
          logfiledir: /var/log/osxhttpd

       proxycachedir: /var/run/proxy
Compilation paths:
          HTTPD_ROOT: /usr 
     SHARED_CORE_DIR: /usr/libexec/osxhttpd
      DEFAULT_PIDLOG: /var/run/osxhttpd.pid
 
DEFAULT_SCOREBOARD: /var/run/osxhttpd.scoreboard
    DEFAULT_LOCKFILE: /var/run/osxhttpd.lock
    DEFAULT_ERRORLOG: /var/log/osxhttpd/error_log
  
TYPES_CONFIG_FILE: /etc/osxhttpd/mime.types 
  SERVER_CONFIG_FILE: /etc/osxhttpd/osxhttpd.conf
  ACCESS_CONFIG_FILE: /etc/osxhttpd/access.conf
RESOURCE_CONFIG_FILE: /etc/osxhttpd/srm.conf

NOTE  Unfortunately, Apache 2ís configure doesnít support this feature yet.



 
 
>>> More Apache Articles          >>> More By Apress Publishing
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

APACHE ARTICLES

- Apache Unveils Cassandra 1.2
- Apache on ARM Chips? Dell and Calxeda Help M...
- The Down Side of Open Source Software
- VMware Unveils Serengeti for Apache Hadoop
- SAP Takes Steps to Improve Hadoop Integration
- Looking to Hone Apache Hadoop Skills?
- How to Install Joomla on WAMPP
- Working with XAMPP and Wordpress
- GUI Available for Apache Camel
- Reduce Server Load for Apache and PHP Websit...
- Creating a VAMP (Vista, Apache, MySQL, PHP) ...
- Putting Apache in Jail
- Containing Intrusions in Apache
- Server Limits for Apache Security
- Setting Permissions in Apache

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: