The best part about Apache is that you can custom build it to include exactly what you need. The defaultconfiguration is a good one, but its far-too-general nature is, by definition, not the best choice for the majority of installations. With a host of plug-in modules available for free over the Internet, customizing Apache to its fullest extent is not only fast and easy, but well worth the time spent.
OK, enough background; let's compile Apache. The actual build process is relatively speedy, for all of the planning that goes into it. Compilation happens in a series of steps, where each module is compiled separately, turned into libraries, and then all those libraries get linked together into a single executable, except when using mod_so, inc which case this step is skipped for modules that are to remain shared.
Case One: ISP (www.foo.isp)
The simplest case is that of the default configuration, for example, something an ISP might use. Since we can accept all the default modules, configuration is a matter of:
# ./configure
That's it. It doesn't get much easier than this. configure is
nice, and warns you about using the default configuration, but in this case, it's what we want so we can ignore it, and proceed with make, make test, and make install. Our completed binary looks like this:
Case Two: Corporate Web Site (www.content-heaven.com)
For this example, we are going to build a copy of Apache for a well-designed commercial website (by well-designed, I mean that we have complete control over what types of files will go on it).
We have no imagemaps or asis files, so we can disable mod_imap and mod_asis. There are no user directories on it, and all directories have index files, so we can disable mod_userdir and mod_autoindex. And, finally, none of our pages require any sort of authentication, so can can disable mod_auth (the other mod_auth_* modules are not compiled in by default). We will keep mod_access, however, to protect our server-status page.
We need mod_status so we can keep track of the status of the server, and mod_access to limit access to that page to our domain only (for internal usage). mod_dir lets us specify that each directory has a default index file of index.shtml. (Using mod_actions, we have defined files with a .shtml extension to be handled by mod_include, which means that the web server will parse them for special processing directives, which it will execute. We have also, through mod_dir, told Apache to serve a file called index.shtml whenever someone requests a directory, i.e., a URL that ends with a /.) These are all enabled by default, and require no extra enable-module directives. Since our marketing department saw fit to publish mixed-case URLs in our advertisements, we will need mod_speling, which makes URLs case insensitive (--enable-module=speling).
Don't forget that when specifying modules to enable or disable, you need to list the name of the module, without the "mod_" prefix.
The standard Apache layout is almost exactly what we need, except for one thing, we would like log files to go into our NFS mounted log directory, /logs/httpd. We can accomplish this by passing --logfiledir=/logs/httpd to the configure script.
Apache will store this in a file called config.status in the
root of the source tree (where the configure script lives), so the build can be duplicated easily (it is informative to look at this file, to see what configure thinks you meant). After this finishes running, you will get your prompt back; type make and watch the messages fly across the screen. Once the compiling is completed (again, when you get your prompt back), make install will put the files into the directories specified by the layout chosen (this may require root access to the machine, depending on where the files are going).
Case Three: Graphics Server (graphics.content-heaven.com)
In addition to the general HTML-serving httpd, Content Heaven, Inc has decided to use a dedicated server specifically for serving their images and graphics. In this common scenario, only a few of Apache's modules are needed, since the server will be doing one thing, and one thing only: sending files from disk over the network. Thus, we can disable many of the standard modules that we left untouched before, such as mod_access, mod_include, mod_index, and mod_cgi, in addition to the ones we had disabled earlier. Finally, let's include mod_rewrite in the graphics server, for redirecting direct requests for graphics.content-heaven.com to www.content-heaven.com.