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
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.
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
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:
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:
You also get a readme file explaining how the archive was built:
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
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:
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:
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
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
blog comments powered by Disqus