Book Review: The Apache Modules Book

The Apache Modules Book is the latest open-source software development book from Prentice Hall. The book forms part of the Open Source Development Series from Prentice Hall, which includes other titles such as Understanding AJAX and Embedded Linux. Dan Wellman looks at this book chapter by chapter to see whether it’s a worthy addition to an open source developer’s library.

Prentice Hall are renowned as a leading publisher of developer focused and educational books, and are America’s leading publisher of academic textbooks. It was written by Nick Kew, and features a foreword from Rich Bowen, both prominent figures in the world of Apache. Nick has decades of professional software and system experience and is a member of both the Apache core development team, and the Apache Software Foundation. The book is priced at a very reasonable $49.99 and the ISBN is 0-12-240967-4.

The book is separated into just 12 chapters. Often technical code-based books can run up to as many as 50 chapters, and many are so big that they are broken down into parts before being broken down further into chapters. Each of these chapters focus on a specific aspect of either the Apache server itself, or the process of creating new modules.

The first chapter is purely concept-based and gives an introduction to the Apache Server and its origins and history. It gives a detailed description of the Apache Software Foundation, including who they are, what they represent, the different levels of developer participation, the development process and information regarding the Apache License (the full license is also included at the end of the book in Appendix A and the Contributor License Agreement as Appendix B).

{mospagebreak title=Chapters Two Through Five}

Chapter two looks at the architecture of Apache and the platform with respect to application programming; it describes in great detail the different operational phases of Apache, what MPMs are and how they interact with the platform. It discusses the basic concepts and structures of the server, looks at some of the configuration basics and gives an overview of how requests are processed by the server. Again, this chapter serves as an introduction to bring you up to speed with how the server works, but unlike chapter one, there are detailed examples of the underlying code of some of the Apache header files, which is a helpful start for people that have only a basic understanding of Apache.

Chapter three delves into the Apache Portable Runtime (APR), which provides a portable, platform-independent layer for applications. APR modules consist of APIs and implementations of the functions contained in the API, and provide a useful abstraction layer between the applications programmer and the native system. Each of the APR functions are listed and described in detail, often with basic examples of use. Information is also provided here that describes processes such as memory management and resource pooling, buckets and brigades and the database module.

Chapter four moves on to discuss programming techniques and best practices that should be used when developing custom Apache modules. This is another scenario-based chapter in which points that are made are reinforced with code examples. The information in these three chapters gives you the foundation you’ll need before beginning modular application development using Apache as a platform. This is a complex subject and at least a fundamental understanding of C is required. Without the information in the first few chapters a lot of the examples later in the book wouldn’t make sense, so it’s great that Nick included this kind of information for newcomers to the field.

Chapter five sees the creation of an actual module that is used and executed by Apache. No programming manual that introduces developers to a new language or platform would be complete without the Hello World! application, so it’s great to see this tradition continued here. Where the preceding chapters were a little complex in places, with some of the examples and topics referring to advanced features and practices, it’s refreshing to come back to a chapter that serves as a beginning and where the examples require a little less brain power to follow.

{mospagebreak title=Chapters Six Through Ten}

The next three chapters look at some request handling fundamentals in more detail. Chapter six looks at the request processing cycle and metadata handlers in great detail and focuses on subjects such as the metadata sent to the server in an HTTP request, how the modules of Apache can hook into this metadata, internal redirection and how the request processing flow is interrupted and diverted to error documents. To show some of the examples illustrated in this chapter working, a new module is also written.

Chapter seven moves on to look at the Apache access, authentication and authorization (AAA) framework in great detail and again provides a lot of example code, although no new modules are produced during this chapter. As the author points out, the need to write modules that deal specifically with AAA is less pressing with the improvements in this area in Apache 2.2; however, including this information helps to refine your knowledge of the subject and prepares you just in case you ever need it.

Chapter eight moves on to discuss the modules that play a part in the filter chain part of the request cycle, and how to develop your own modules that work with filters. Two example modules are created in this chapter, each exposing different aspects of this large topic. Again this is a great chapter for expanding your all-round working knowledge of Apache, and where words fail to completely describe different filter concepts, flow diagrams are included to maximize your learning of the subject. The chapter goes into fine detail about the input and output filters, the code that drives them and the function of each. These three chapters also contain a lot of information on how Apache works that will be of use to anyone that wants to learn about the web server, not just those interested in writing custom modules.

In chapter nine, the author looks at the different methods for exposing your custom modules to configuration, so that administrators or users can control how your modules function. Apache, as any administrator will know, is configured with the use of directives added to the httpd.conf file, and this chapter looks in detail at how similar configuration settings are created to apply to your module.

Chapter ten looks at extending the API in order to implement new API functions, implement new hooks, and provide services. Processing hooks work with the requests that the server receives and a thorough explanation of how hooks work is also provided. A lot of information is also given in this chapter about how modules can interact with each other through exported functions and services.

{mospagebreak title=The Last Two Chapters and Final Thoughts}

The next chapter begins with a brief look at the way Apache has evolved over previous versions of the software with regard to databases and looks at the classic LAMP architecture. The Apache database framework is examined in detail, as well as the DBD architecture, The chapter also covers using DBD in a module and discusses, with full examples, how to write your own driver to add support for a database type not supported by the DBD module. This is one area in which Nick Kew is highly respected, having written the dbd_apr module himself.

The final chapter looks at the all-important aspect of debugging modules that you have written. No one writes a complete module for the first time without making a single error, and this chapter provides the means for tracking down and eliminating bugs in your code. It deals specifically with the make up and use of the error log, running Apache under a widely-used debugger and how to trace server crashes. It also looks at using a diagnostic module that looks for problems in filter modules, and the author gives a personal example of how this module had been used to track down a problem with the third-party library libxml2. All in all this is an excellent way to end the main body of the book, but there is also a lot of information that can be found in the appendices.

The book’s main focus is using Apache and the HTTP protocol as a basis for applications programming and it helpfully provides the entire HTTP 1.1 protocol as Appendix C. This is great because it means that you can get by using just this one book to learn how to program modules and as the reference you’re going to need with respect to HTTP; you don’t need to rush off and buy a separate book or spend time looking for the references elsewhere.

One final "feature" of the book that is worth mentioning is that it is Safari Books Online Enabled. Safari Bookshelf is an electronic reference library that allows you to search thousands of online technical reference manuals. You get a 45-day free trial and access to the online version of the book is obtained using the coupon code found in the first few pages of the book. Now if you leave the book at home but find that your need to access it while at work, you can just log on and dive in.

Overall, I thought the book was very well written; the subject is broken into well sized chapters that flow smoothly, the style is engaging and Nick Kew does an excellent job of bringing a complex and code-heavy subject to life, a character that many technical reference books simply lack. As the sole book in existence dedicated to teaching people how to write custom Apache Modules to turn Apache into an application platform, it is a must for anyone that is interested in this area of programming.

[gp-comments width="770" linklove="off" ]

chat