Apache
  Home arrow Apache arrow Page 7 - Building Apache the Way You Want It
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
APACHE

Building Apache the Way You Want It
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 11
    2005-08-18

    Table of Contents:
  • Building Apache the Way You Want It
  • Building Apache from Source
  • General Options
  • Enabling or Disabling Modules in Bulk
  • Changing the Module Order (Apache 1.3)
  • Building Apache from Source As an RPM (Apache 2)
  • Advanced Configuration
  • Determining Apache’s Locations Individually
  • Choosing a MultiProcessing Module (Apache 2)
  • Building Apache with suExec support
  • Configuring Apache 2 for Cross-Platform Builds
  • Configuring the Build Environment
  • Building Modules with apxs

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Building Apache the Way You Want It - Advanced Configuration
    (Page 7 of 13 )

    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


       · This article (chapter) is better then most full books I have on Apache and I do have...
     

    Buy this book now. This article is from chapter three of the book Pro Apache third edition, written by Peter Wainwright (Apress, 2004; ISBN: 1590593006). Check it out at your favorite bookstore. Buy this book now.

       

    APACHE ARTICLES

    - Putting Apache in Jail
    - Containing Intrusions in Apache
    - Server Limits for Apache Security
    - Setting Permissions in Apache
    - Installing Apache
    - Apache Installation and Configuration
    - Apache Tapestry and Custom Components: DateI...
    - Tapestry and AJAX: Autocompleter and InlineE...
    - PropertySelection and IPropertySelectionMode...
    - The DatePicker and Shell Components of Apach...
    - Apache Tapestry: ASO and More Components
    - Apache Tapestry and DirectLink, IoC and DI
    - Making a CelebrityCollector with Apache Tape...
    - Apache Tapestry and Listener Methods, Condit...
    - The Properties of Tapestry Pages

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway