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 LayoutYou’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 SchemeThe 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: $ ./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 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 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 |
|
|
|
|
|
|
|