Apache Cookbook
Rich Bowen
Ken Coar
Copyright 2009 Ken Coar and Rich Bowen
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (.
Nutshell Handbook, the Nutshell Handbook logo, and the OReilly logo are registered trademarks of OReilly Media, Inc. The Cookbook series designations, Apache Cookbook, the image of a moose, and related trade dress are trademarks of OReilly Media, Inc.
Many of the designations uses by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and OReilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
This book uses RepKover, a durable and flexible lay-flat binding.
O'Reilly Media
Preface
The Apache Web server is a remarkable piece of software. The basic package distributed by the Apache Software Foundation is quite complete and very powerful, and a lot of effort has gone into keeping it from suffering software bloat. One facet of the package makes it especially remarkable: it includes extensibility by design. In short, if the Apache package right out of the box does not do what you want, you can generally extend it so that it does. Dozens of extensions (called modules) are included as part of the package distributed by the Apache Software Foundation. And if one of these doesnt meet your needs, with several million users out there, there is an excellent chance someone else has already done your work for you, someone who has concocted a recipe of changes or enhancements to the server that will satisfy your requirements.
This book is a collection of these recipes. Its sources include tips from the firehose of the Usenet newsgroups, the Apache FAQ, Apache-related mailing lists, mail containing how-to questions, questions and problems posed on IRC chat channels, and volunteered submissions.
All of the items in this book come from real-life situations, encountered either by us or by other people who have asked for our help. The topics range from basic compilation of the source code to complex problems involving the treatment of URLs that require SSL encryption.
Weve collected more than a hundred different problems and their solutions, largely based on how often they occurred, and have grouped them roughly by subject as shown in .
Primarily, these recipes are useful to webmasters who are responsible for the entire server; however, many are equally applicable to users who want to customize the behavior in their own Web directories through the use of .htaccess
files.
Weve written the Apache Cookbook to be a practical reference, rather than a theoretical discourse: reading it recipe by recipe, chapter by chapter, isnt going to reveal a plot (Roy Fielding in the Library with an RFC![]). Its intended to provide point solutions to specific problems, located through the table of contents or the index.
Whats in This Book
Because much of the material in this book is drawn from question-and-answer discussions and consultations, we have tried to make it as complete as possible. Of course, this means that we have included recipes for some questions to which there are currently no satisfactory answers (at least to our knowledge). This has not been done to tease, annoy, or frustrate you; such recipes are included to provide completeness, so that you will know those problems have been considered rather than ignored.
Very few problems remain insoluble forever, and these incomplete recipes are the ones that will receive immediate attention on the books Web site and in revisions of the book. If a reader has figured out a way to do something the book mentions but doesnt explain, or omits mentioning entirely, our research team can be notified, and that solution will go on the Web site and in the next revision.
Who knows, you may be the one to provide such a solution!
[] An obscure reference to a board game called Clue and an obscure developer of HTTP.
Platform Notes
The recipes in this book are geared toward two major platforms: Unixish (such as Linux, FreeBSD, and Solaris) and Windows. There are many that have no platform-specific aspects, and for those, any mention of the underlying operating system or hardware is gratefully omitted. Because of the authors personal preferences and experiences, Unixish coverage is more complete than that for the Windows platforms. However, contributions, suggestions, and corrections for Windows-specific recipes will be gladly considered for future revisions and inclusion on the Web site.
Other Books
There are a number of books currently in print that deal with the Apache Web server and its operation. Among them are:
Apache: The Definitive Guide, Third Edition, by Ben and Peter Laurie (OReilly)
Pro Apache, Third Edition, by Peter Wainwright (Apress)
Apache Administrators Handbook by Rich Bowen, et al. (Macmillan)
You can also keep an eye on a couple of Web pages that track Apache titles:
Other Sources
In addition to books, there is a wealth of information available online. There are Web sites, mailing lists, and Usenet newsgroups devoted to the use and management of the Apache Web server. The Web sites are limitless, but here are some active and useful sources of information:
The comp.infosystems.www.servers.unix and comp.infosystems.www.servers. ms-windows Usenet newsgroups. Although these arent dedicated to Apache specifically, there is a lot of traffic concerning it, and experienced Apache users hang out here. If you dont have access to news, or don't know how to reach Usenet, check out http://groups.google.com/.
The Apache Today Web site, http://apachetoday.com/, run by Internet.com. This site regularly lists articles about the Web server and making the most of it.
The .
The #apache IRC channel on the irc.freenode.net networkor on many other IRC networks, for that matter. However, your chances of encountering us are most likely on the freenode network.
We must point out that none of these are official support mediums for the Web server. In fact, there is no official support path, since the software is largely developed by volunteers and is free. However, these informal support forums successfully answer many questions.
How This Book Is Organized
This book is broken up into 13 chapters and 2 appendixes, as follows:
, covers the basics of installing the vanilla Apache software, from source on Unixish systems, and on Windows from the Microsoft Software Installer (MSI) package built by the Apache developers.
, describes the details of installing some of the most common third-party modules, and includes generic instructions that apply to many others that have less complex installation needs.
, includes recipes about recording the visits to your Web site(s), and Apaches error logging mechanism.