Home arrow Site Administration arrow Page 6 - How To Build the Apache of Your Dreams

Building Apache, Really - Administration

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.

  1. How To Build the Apache of Your Dreams
  2. Building Apache
  3. Module Definitions and Groupings
  4. Diversion: Shared Modules (mod_so)
  5. Diversion: Layouts
  6. Building Apache, Really
  7. Last Thoughts
  8. References
By: Darren Chamberlain
Rating: starstarstarstarstar / 3
September 19, 2000

print this article


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:

# /usr/local/apache/bin/httpd -l Compiled-in modules: http_core.c mod_env.c mod_log_config.c mod_mime.c mod_negotiation.c mod_status.c mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_asis.c mod_imap.c mod_actions.c mod_userdir.c mod_alias.c mod_access.c mod_auth.c mod_setenvif.c

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.

Here is what we will type at the command line:

# cd /usr/local/src/apache_1.3.12 # ./configure --with-layout=Apache \ --logfiledir=/logs/httpd \ --enable-module=speling \ --disable-module=imap \ --disable-module=asis \ --disable-module=userdir \ --disable-module=autoindex \ --disable-module=auth \ --verbose
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).

Our finished binary looks like:

# /usr/local/apache/bin/httpd -l Compiled-in modules: http_core.c mod_env.c mod_log_config.c mod_mime.c mod_negotiation.c mod_status.c mod_include.c mod_dir.c mod_cgi.c mod_actions.c mod_speling.c mod_alias.c mod_access.c mod_setenvif.c
Slim, compact, and to the point.

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.

Our configure command looks like this:

# ./configure --with-layout=Apache \ --logfiledir=/logs/httpd \ --disable-module=imap \ --disable-module=asis \ --disable-module=userdir \ --disable-module=autoindex \ --disable-module=auth \ --disable-module=access \ --disable-module=include \ --disable-module=dir \ --disable-module=cgi \ --disable-module=env \ --disable-module=setenvif \ --disable-module=negotiation \ --enable-module=rewrite \ --verbose
Notice that is looks very similar to the previous example. Once it has completed compiling, our binary looks like this:

# /usr/local/apache/bin/httpd -l Compiled-in modules: http_core.c mod_log_config.c mod_mime.c mod_status.c mod_actions.c mod_alias.c mod_rewrite.c
This is even more slimmed down that the previous one, and contains only the exact modules we need.

{mospagebreak title=Apache Module Registry}

The Apache Module Registry is your key to a really cool customized web server. There are tons of modules to do things like authentication and parameter parsing, embedded languages like mod_perl, Java (with Apache JServ, allowing for embedded Java, and The Jakarta Project, a JSP implementation), mod_snake (for Python), and mod_tcl, and others.

>>> More Site Administration Articles          >>> More By Darren Chamberlain

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Coding: Not Just for Developers
- To Support or Not Support IE?
- Administration: Networking OSX and Win 7
- DotNetNuke Gets Social
- Integrating MailChimp with Joomla: Creating ...
- Integrating MailChimp with Joomla: List Mana...
- Integrating MailChimp with Joomla: Building ...
- Integrating MailChimp with Joomla
- More Top WordPress Plugins for Social Media
- Optimizing Security: SSH Public Key Authenti...
- Patches and Rejects in Software Configuratio...
- Configuring a CVS Server
- Managing Code and Teams for Cross-Platform S...
- Software Configuration Management
- Back Up a Joomla Site with Akeeba Backup

Developer Shed Affiliates


Dev Shed Tutorial Topics: