Introducing AxKit
by Barrie Slaymaker
|
Pages: 1, 2, 3
Basic Installation
This section will walk you through a manual installation, but there's an easier way if you just want to play with AxKit: grab the AxKit demo tarball for this article, untar it and run the install script therein. The tarball includes the prerequisites necessary for most modern Unix-like systems and will be updated new versions and example code with each article. If this works for you (it's been tested on both Linux and FreeBSD), you can skip all of the manual install instructions and jump to Testing AxKit.
AxKit ties together a lot of different technologies and uses a lot of CPAN modules. Doing a basic manual install is not difficult if CPAN.pm (or equivalent; a CPANPLUS is in the works as of this writing) is working on your system.
The first step in installing AxKit is big, but not usually difficult: installing Apache and mod_perl 1.x versions (2.x versions are in development but are not released at the time of this writing). The mod_perl Developer's Guide covers this process in detail. Here's a quick recipe for a Unix system "private" (ie non-root) install in /home/me/axkit_articles-1.0 (vary the version numbers to suit):
$ mkdir axkit_articles-1.0 $ cd axkit_articles-1.0 $ lynx http://httpd.apache.org/dist/httpd/ # Get the latest 1.x version of apache $ lynx http://perl.apache.org/dist/ # Get the latest 1.x version of mod_perl. $ gunzip apache_1.3.23.tar.gz $ tar xf apache_1.3.23.tar $ gunzip mod_perl-1.26.tar.gz $ tar xf mod_perl-1.26.tar $ cd mod_perl-1.26 $ perl Makefile.PL \ > APACHE_SRC=../apache_1.3.23/src/ \ > DO_HTTPD=1 \ > USE_APACI=1 \ > APACHE_PREFIX=/home/me/axkit_articles-1.0/www \ > PREFIX=/home/me/axkit_articles-1.0/www \ > EVERYTHING=1 $ make $ make test $ make install
It is usually wise to write your AxKit/mod_perl/Apache build process in to a script so that you can debug it, repeat it, and alter it as needed. Servers like these are immensely powerful and configurable; it's pretty likely that you'll want a reproducable, tweakable build environment for them.
On Windows, look for the most recent Apache Win32 binary in http://httpd.apache.org/dist/binaries/win32/ and then use PPM to install a mod_perl binary. NOTE: it is not recommended to use Windows for production Apache/mod_perl servers; Apache/mod_perl 1.x is not able to scale well on this platform; Apache/mod_perl 2.x is addressing the fundamental architectural disagreements that cause this.
If all went well, running
$ www/bin/apachectl start
should fire up a (non-AxKit) httpd on port 8080. In case of trouble (both packages are mature, so trouble is not frequent), see the References and Helpful Resources section at the end of the article for some places to seek help.
The next part is to install some AxKit prerequisites: the GNOME project's libxml2 and libxslt will be used by the examples in this series of articles, though they project's libxml2. To see if they are already installed, try:
$ xml2-config --version 2.4.13 # Need >= 2.4.13 $ xslt-config --version 1.0.10 # Need >= 1.0.10
If not, grab them from the source tarball for the article or a random GNOME mirror and install them using ./configure && make && make install. The tarball above installs all of the prerequisites in the "private" install tree; here we're installing them in the system's shared locations to keep the manual install easy. See the commands generated by the install script if you want private copies.
Please note: libxslt 1.0.10 has a known (very minor) failure in its test suite which causes make to fail on some systems when testing tests/exslt/sets/has-same-node.1.xsl. The install script provided with this article's source tarball removes the offending test before running make.
Now that all of the major prerequisites are installed, let's let CPAN.pm install the final pieces:
$ su Password: # perl -MCPAN -e shell ... cpan> install XML::LibXSLT ... cpan> install AxKit::XSP::Util ... cpan> quit # exit
The AxKit::XSP::Util installation should install AxKit and a number of other prerequisites. If CPAN.pm does not work for you, you might just want to grab the axkit-demo tarball mentioned above and install the packages you find there by hand. There are a lot of them, though, so getting CPAN working is propably the easiest way to do a manual install.
Testing AxKit
All of the relative directories mentioned from now on assume that you are in the axkit_articles-x.y directory unless otherwise indicated.
Once all of the required modules are installed, tweak the www/conf/httpd.conf file to load AxKit by adding:
##
## AxKit Configuration
##
PerlModule AxKit
<Directory "/home/me/axkit_articles-1.0/www/htdocs">
Options -All +Indexes +FollowSymLinks
# Tell mod_dir to translate / to /index.xml or /index.xsp
DirectoryIndex index.xsp
AddHandler axkit .xml .xsp
AxDebugLevel 10
AxGzipOutput On
AxAddXSPTaglib AxKit::XSP::Util
AxAddStyleMap application/x-xsp \
Apache::AxKit::Language::XSP
</Directory>
We'll walk through the configuration in a bit, but first let's add a www/htdocs/index.xsp test page that looks like:
<?xml-stylesheet href="NULL" type="application/x-xsp"?>
<xsp:page
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:util="http://apache.org/xsp/util/v1"
>
<html>
<body>
<p>Hi! It's <util:time format="%H:%M:%S"/>.</p>
</body>
</html>
</xsp:page>
Now you should be able to restart the server and request the test page like so (whitespace added for readability and so it can be compared to index.xsp easily):
$ www/bin/apachectl restart $ lynx -source http://127.0.0.1:8080/ <?xml version="1.0" encoding="UTF-8"?> <html> <body> <p>Hi! It's Tue Feb 5 16:26:31 2002.</p> </body> <html>
Each request should generate a new page with a different time stamp. You may need to tweak the Port directive in www/conf/httpd.conf if something's already running on port 8080.

