Sean’s Obsessions

Sean Walberg’s blog

Review: Apache Cookbook

0596001916.01._PE30_PI_SCMZZZZZZZ_.jpgApache Cookbook
Ken Coar & Rich Bowen
O’Reilly, 2004
234pp, $29.95USD/$46.95CDN

I finished going through O’Reilly’s Apache Cookbook a little while back, but it came in handy so often at work, I never brought it home to complete the review!

Like the other entries in the Cookbooks Series, the Apache Cookbook focuses on common problems, their solutions, and an explanation of the thought process behind it. For an application such as Apache, this is the perfect way to help people out.

Each recipe poses a common problem, such as how to install the web server or a module, a concise solution, and a discussion of how the solution works. Even though some solutions are “there is no solution” (such as how to log the IP address of a proxied client), the fact that it is stated as such, along with an explanation of why (either technically impossible, or no such software written) is still helpful.

The breadth of topics is good, starting out on basic installation from source, RPM, or helper scripts, moving onto logging, virtual hosts, and security, and covering more advanced topics such as proxying and url rewriting.

I found that the books treatment of logging, normally a mundane topic, was particularily good. Many of the recipes may not have had immediate practical value, such as logging cookies, but they all showed off how versatile Apache is. The procedure for logging a cookie turns out to be fairly simple, but in doing so the reader is shown the many ways that the CustomLog directive can be used. For logging proxied requests, something that this author has unsuccessfully tried to do in the past, the answer turns out to show off some Apache features that let the administrator set environment variables for the request that get picked up later in the process. Along with logging specific things, alternate methods of logging, such as SQL and Syslog, are also shown. Surprisingly, I saw no mention of what to do with the logs once they’ve hit disk, even if it were a few links to packages such as Webalizer or AWStats

Chapter 5, “Aliases, Redirecting, and Rewriting” shows some of the more powerful aspects of Apache, namely its ability to manipulate any aspect of the query. There are several practical recipes here, such as moving parts of your site to another url, mapping several URLs into one file, and so forth. This chapter shows off many of the regular expression features, not only the obvious sledgehammer of mod_rewrite, but many of the Match commands, such as RedirectMatch, and ScriptAliasMatch.

The chapter on SSL is also very helpful, guiding the user through many scenarios such as generating keys, requiring SSL for certain sections of the site, and even using client certificates.

Likewise, the chapters on proxies and performance are excellent if the topic is of interest to you, or you find yourself in need.

The book covers both Apache 1.3 and 2.0, being careful to make notes where the configurations differ.

I brought this book in to work when I first got it, which coincidentally was around the time where some of us were doing some Apache work. The book proved indispensible, answering everything from “Why does the site work with a trailing slash, but not without?” (hint, check your ServerName directive) to setting up SSL and some site redirections. This book will be close at hand the next time I have an Apache question.

Apache Cookbook combines an easy to follow writing style with a format conducive to solving problems. Anyone who works with Apache will want this book handy.

Comments

I’m trying something new here. Talk to me on Twitter with the button above, please.