How To Build the Apache of Your Dreams - Diversion: Layouts (
Page 5 of 8 )
Using
--with-layout you can easily indicate where should Apache go after it's
compiled. Locations for binaries, man pages, configuration files, and the like
can be set using specific options to the configure script, or they can be
defined all at once in a layout. Layouts are defined in the config.layout file,
in the root of the Apache source. There are several layouts prefined, including
Mac OS X server, BeOS, a typical GNU layout, and others. We'll use the layout
named Apache as an example, since it's the default; if a layout is not
specified, configure uses the Apache layout as a base, and any command l ine
options overrride individual directives. (The comments on the right hand side of
this table indicate the command line options that can be used for overrides.)
<Layout Apache>
prefix: /usr/local/apache # --prefix=DIR
exec_prefix: $prefix # --exec-prefix=DIR
bindir: $exec_prefix/bin # --bindir=DIR
sbindir: $exec_prefix/bin # --sbindir=DIR
libexecdir: $exec_prefix/libexec # --libexecdir=DIR
mandir: $prefix/man # --mandir=DIR
sysconfdir: $prefix/conf # --sysconfdir=DIR
datadir: $prefix # --datadir=DIR
iconsdir: $datadir/icons # --iconsdir=DIR
htdocsdir: $datadir/htdocs # --htdocsdir=DIR
cgidir: $datadir/cgi-bin # --cgidir=DIR
includedir: $prefix/include # --includedir=DIR
localstatedir: $prefix # --localstatedir=DIR
runtimedir: $localstatedir/logs # --runtimedir=DIR
logfiledir: $localstatedir/logs # --logfiledir=DIR
proxycachedir: $localstatedir/proxy # --proxycachedir=DIR
</Layout>
These sections define where the various pieces of the final
package will go. The whole thing will based in /usr/local/apache, with all
binaries (httpd and the support programs) in /usr/local/apache/bin, man pages
based in /usr/local/apache/man, configuration files in /usr/local/apache/conf,
and so on. Changes to the layout can be made to one of the existing
<Layout> sections, or a new one can be added by copying and
pasting.
Here is the layout similar to the one that I generally use:
<Layout MyLayout>
prefix: /usr/local/apache
exec_prefix: $prefix
bindir: $exec_prefix/bin
sbindir: $exec_prefix/bin
libexecdir: $exec_prefix/libexec
mandir: /usr/local/man
sysconfdir: /etc/apache
datadir: $prefix
iconsdir: $datadir/icons
htdocsdir: $datadir/html
cgidir: $datadir/cgi-bin
includedir: /usr/include/apache
localstatedir: /var/apache
runtimedir: $localstatedir/logs
logfiledir: $localstatedir/logs
proxycachedir: $localstatedir/proxy
</Layout>
This is very similar to the Apache layout, except for a few
things: man pages go into /usr/local/man, so they can be easily retrieved with a
regular call to 'man httpd'; include files go into /usr/include/apache, so that
they can be more easily used when I write to the Apache API, and configuration
files go into /etc/apache. Logs, proxy stuff, and things like PID files go into
/var/apache; I mount a separate partition as /var so my root filesystem doesn't
fill up with logs, which makes it an ideal place for webserver
logs.