AxKit combines the power of Perl’s rich and varied XML processing facilities with the flexibility of the Apache web server. But instead of using a monolithic package, it takes a more modular approach. This allows developers great flexibility in choosing what lower-level packages they want, but it can mean a more lengthy and complicated installation process. This article comes from chapter two of the book XML Publishing with AxKit by Kip Hampton (O'Reilly, 2004; ISBN: 0596002165).
AxKit combines the power of Perl’s rich and varied XML processing facilities with the flexibility of the Apache web server. Rather than implementing such an environment in a monolithic package, as some application servers do, it takes a more modular approach. It allows developers to choose the lower-level tools such as XML parsers and XSLT processors for themselves. This neutrality with respect to lower-level tools gives AxKit the ability to adapt and incorporate new, better performing, or more feature-rich tools as quickly as they appear. That flexibility costs, however. You will probably have to install more than just the AxKit distribution to get a working system.
To get AxKit up and running, you will need:
The Apache HTTP server (Version 1.3.x)
The mod_perl Apache extension module (Version 1.26 or above)
An XML parser written in Perl or, more commonly, one written in C that offers a Perl interface module
The core AxKit distribution
Installing Apache and mod_perl
If you are running an open source or open source–friendly operating system such as GNU/Linux or one of the BSD variants (including Mac OS X), chances are good that you already have Apache and mod_perl installed. If this is the case, then you probably will not have to install them by hand. Simply make sure that you are running the most recent version of each, and skip directly to the next section. However, in some cases, using precompiled binaries of Apache and mod_perl proved to be problematic for people who want to use AxKit. In most cases, neither the binary in question, nor AxKit, are really broken. The problem lies in the fact that binaries built for public distribution are usually compiled with a set of general build arguments, not always well suited for specialized environments such as AxKit. If you find that all AxKit’s dependencies install cleanly, but AxKit’s test suite still fails, you may consider removing the binary versions and installing Apache and mod_perl by hand. At the time of this writing, AxKit runs only under Apache versions in the 1.3. x branch. Support for Apache 2. x is currently in development. Given that Apache 2 is quite different from previous versions, both in style and substance, the AxKit development team decided to take things slowly to ensure that AxKit for Apache 2. x offers the best that the new environment has to offer.
To install Apache and mod_perl from the source, you need to download the source distributions for each from http://httpd.apache.org/ and http://perl.apache.org/, respectively. After downloading, unpack both distributions into a temporary directory and cd into the new mod_perl directory. A complete reference for all options available for building the Apache server and mod_perl is far beyond the scope of this book. The following will get you up and running with a useful set of features:
All lines before the make command are build flags that are being passed to perl Makefile.PL. The \ characters are simply part of the shell syntax that allows you to divide the arguments across multiple lines. The > characters represent the shell’s output, and you should not include them. Also, be sure to replace the value of the APACHE_SRC option with the actual name of the directory into which you just unpacked the Apache source.
XML Processing Options
As I mentioned in the introduction to this chapter, AxKit is a publishing and application framework. It is not an XML parser or XSLT processor, but it allows you to choose among these lower-level tools while ensuring that they work together in a predictable way. If you do not already have the appropriate XML processing tools installed on your server, AxKit attempts to install the minimum needed to serve transformed XML content. However, more cautious minds may prefer to install the necessary XML parser and any optional XSLT libraries to make sure they work before installing the AxKit core. Deciding which XML parsers or other libraries to install depends on your application’s other XML processing needs, but the following dependency list shows which tools AxKit currently supports and which publishing features require which libraries.
Gnome XML parser (libxml2) Requires: XML::LibXML Required by AxKit for: eXtensible Server Pages Available from: http://xmlsoft.org/ Expat XML parser Requires: XML::Parser Required by AxKit for: XPathScript Available from: http://sourceforge.net/projects/expat/ Gnome XSLT processor (libxslt) Requires: libxml2,XML::LibXSLT Required by AxKit for: optional XSLT processing Available from: http://xmlsoft.org/XSLT/ Sablotron XSLT processor Requires: Expat, XML::Sablotron Required by AxKit for: optional XSLT processing Available from: http://www.gingerall.com/
You do not need to install all these libraries before installing AxKit. For example, if you plan to do XSLT processing, you need to install either libxslt or Sablotron, not both. However, I do strongly recommend installing both supported XML parsers: Gnome Project’s libxml2 for its speed and modern features, and Expat for its wide use among many popular Perl XML modules. In any case, remember that you must install the associated Perl interface modules for any of the C libraries mentioned above, or AxKit will have no way to access the functionality that they provide.
Again, some operating system distributions include one or more of the libraries mentioned above as part of their basic packages. Be sure to upgrade these libraries before proceeding with the AxKit installation to ensure that you are building against the most recent stable code.