Mon Nov 1 08:38:29 2004

AxKit on Red Hat 9

Benjamin Boksa, benjamin@boksa.de

Introduction

This document might contain errors, please feel free to fix them.

The following document will tell you how I installed a new Red Hat 9 System with Apache (mod_perl and mod_ssl) and AxKit. It includes building a clean version of Perl 5.8.0 as the one shipping with RedHat 9 is not very useful to us.

It is derived from the documentation of a machine setup I did for one of our customers and I left out some things from this documentation, so if this causes any errors please forgive me.

Setting up a fresh Red Hat 9 machine

Use (after adjusting it to your needs) the following Kickstart file (espacially the %packages section is important).

install
cdrom
lang en_US
langsupport --default en_US en_US.UTF-8 de_DE.UTF-8 en_US de_DE
keyboard de-latin1-nodeadkeys
mouse none
skipx
network --device eth0 --bootproto static --ip 192.168.0.1 \
--netmask 255.255.255.0 --gateway 192.168.0.1 --nameserver 192.168.0.1 \
--hostname axkit.mynetwork.tld 
firewall --disabled
authconfig --enableshadow --enablemd5
bootloader --location=mbr --useLilo

%packages
binutils
cpp
glibc-kernheaders
glibc-devel
binutils
gcc
libstdc++-devel
gcc-c++
patch
zlib-devel
db4-devel
-parted
-kernel-pcmcia-cs
-man-pages-de
-aspell-de
-rhpl
-jfsutils
-lha
-dhclient
-ash
-gpm
-lrzsz
-isdn4k-utils
-gnupg
-wireless-tools
-redhat-config-mouse
-unix2dos
-pam_krb5
-irda-utils
-expat
-perl-Filter
-lokkit
-redhat-config-network-tui
-cyrus-sasl-plain
-rp-pppoe
-ppp
-dos2unix
-python-optik
-lftp
-apmd
-fbset
-reiserfs-utils
-raidtools
-perl
-pinfo
-tcsh
-pspell
-logwatch
-talk
-hesiod
-wvdial
-python
-ed
-sendmail
-mt-st
-pam_smb
-ypbind
-vixie-cron
-up2date
-cpio
-pyxf86config
-vconfig
-mailcap
-krbafs
-autofs
-yp-tools
-rhnlib
-utempter
-pax
-rpm-python
-aspell
-pyOpenSSL
-minicom
-grub
-anacron
-hotplug
-file
-star
-telnet
-usbutils
%post

Changing the default system language

After the basic installation is done and the system has been booted for the first time we will change the default language of the system.

Go to /etc/sysconfig/i18n and change the line starting with LANG to LANG=en_US or something equivalent not using UTF-8.

After having changed the system language reboot the machine to make sure the new value for LANG is propagated.

Installing Perl 5.8.0

As we have excluded Perl in the basic installation of the system the first thing to do now is to install Perl. Use the following commands to install Perl using the default values for the questions during configuration.

echo "/usr/local/lib" >> /etc/ld.so.conf

ldconfig

cd /tmp

wget http://www.cpan.org/src/stable.tar.gz
mv stable.tar.gz /usr/local/src

cd /usr/local/src

tar xvfz stable.tar.gz

cd perl-5.8.0

./Configure -de -Dprefix=/usr/local

make

make test

make install

Type perl -v and enjoy your Perl 5.8.0 installation. To have the famous CPAN module ready for installing other perl modules later do the following:

perl -MCPAN -e shell
  [CPAN] Are you ready for manual configuration? [yes] <no><enter>
[] install Bundle::CPAN 
  [libnet]: Do you want to modify/update your configuration (y|n) ? [no] <enter>
  [Term::Readline]: Enter arithmetic or Perl expression: exit<enter>
[] reload cpan

Installing OpenSSL

The next step is to install OpenSSL which is needed for mod_ssl.

cd /tmp
wget http://www.openssl.org/source/openssl-0.9.7b.tar.gz
mv openssl-0.9.7b.tar.gz /usr/local/src
cd /usr/local/src
tar xvfz openssl-0.9.7b.tar.gz
cd openssl-0.9.7b
./config no-idea no-rc5 shared --openssldir=/usr/local/openssl
make depend
make
make test
make install
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig

Installing Apache 1.3.27 with mod_ssl and mod_perl

Before installing mod_perl we have to make sure that some of the modules needed by mod_perl are installed. Please do the following to install them.

perl -MCPAN -e shell
[] install LWP::UserAgent
  [LWP::UserAgent] Do you want to install lwp-request? [y] <n><enter>
  [LWP::UserAgent] Do you want to install lwp-mirror? [y] <n><enter>
  [LWP::UserAgent] Do you want to install lwp-rget? [y] <n><enter>
  [LWP::UserAgent] Do you want to install lwp-download? [y] <n><enter>
  [HTML::Parser] Do you want decoding on unicode entities? [no] <enter>

After the modules above have been installed the next thing is to install Apache with mod_ssl and mod_perl. I will not go into the details of the installation in the document so make sure you understand the steps below.

cd /tmp

wget http://www.modssl.org/source/mod_ssl-2.8.14-1.3.27.tar.gz
mv mod_ssl-2.8.14-1.3.27.tar.gz /usr/local/src

wget http://perl.apache.org/dist/mod_perl-1.0-current.tar.gz
mv mod_perl-1.0-current.tar.gz /usr/local/src

wget http://www.apache.org/dist/httpd/apache_1.3.27.tar.gz
mv apache_1.3.27.tar.gz /usr/local/src

cd /usr/local/src

tar xvfz mod_ssl-2.8.14-1.3.27.tar.gz
tar xvfz mod_perl-1.0-current.tar.gz
tar xvfz apache_1.3.27.tar.gz

# /www will be the directory where our sites will go

mkdir /www

# configuring mod_ssl

cd /usr/local/src/mod_ssl-2.8.14-1.3.27

./configure --with-apache=/usr/local/src/apache_1.3.27

# configuring and building mod_perl

cd /usr/local/src/mod_perl-1.28

perl Makefile.PL \
EVERYTHING=1 \
APACHE_SRC=../apache_1.3.27/src \
USE_APACI=1 \
PREP_HTTPD=1 \
DO_HTTPD=1

make

make install

# configuring and building apache
cd /usr/local/src/apache_1.3.27

SSL_BASE=/usr/local/openssl \
./configure \
--prefix=/usr/local/apache \
--enable-module=so \
--enable-module=ssl \
--enable-shared=ssl \
--enable-module=rewrite \
--enable-suexec \
--suexec-caller=nobody \
--suexec-docroot=/www \
--suexec-gidmin=1 \
--suexec-logfile=/usr/local/apache/logs/suexec.log \
--activate-module=src/modules/perl/libperl.a \
--enable-module=perl \
--enable-module=info \
--enable-shared=info \
--disable-rule=EXPAT

make

make install

# making sure apache will be started on reboot

cd /etc/rc.d/init.d
ln -s /usr/local/apache/bin/apachectl httpd
cd /etc/rc.d/rc0.d
ln -s ../init.d/httpd K20httpd
cd /etc/rc.d/rc1.d
ln -s ../init.d/httpd K20httpd
cd /etc/rc.d/rc2.d
ln -s ../init.d/httpd K20httpd
cd /etc/rc.d/rc3.d
ln -s ../init.d/httpd S81httpd
cd /etc/rc.d/rc4.d
ln -s ../init.d/httpd S81httpd
cd /etc/rc.d/rc5.d
ln -s ../init.d/httpd S81httpd
cd /etc/rc.d/rc6.d
ln -s ../init.d/httpd K20httpd

/etc/rc.d/init.d/httpd start

Installing AxKit (and libiconv, libxml2, libxslt, libghttp, Expat, Sablot)

This is the largest bunch of installations that have to be performed.

libiconv

The first thing we will install is libiconv:

cd /tmp

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.8.tar.gz
mv libiconv-1.8.tar.gz /usr/local/src

cd /usr/local/src

tar xvfz libiconv-1.8.tar.gz

cd libiconv-1.8

./configure

make

make check

make install

libxml2

After libiconv has been installed we now will install libxml2:

cd /tmp

wget --passive-ftp ftp://ftp.gnome.org/pub/GNOME/sources/libxml2/2.5/libxml2-2.5.7.tar.gz
mv libxml2-2.5.7.tar.gz /usr/local/src

cd /usr/local/src

tar xvfz libxml2-2.5.7.tar.gz

cd libxml2-2.5.7

./configure --without-threads

make

make check

make install

libxslt

As you might have guessed already the next thing to do is to install libxslt:

cd /tmp

wget --passive-ftp ftp://ftp.gnome.org/pub/GNOME/sources/libxslt/1.0/libxslt-1.0.30.tar.gz
mv libxslt-1.0.30.tar.gz /usr/local/src

cd /usr/local/src

tar xvfz libxslt-1.0.30.tar.gz

cd libxslt-1.0.30

./configure

make

make check

make install

libghttp

Another easy installation is libghttp:

cd /tmp

wget --passive-ftp ftp://ftp.gnome.org/pub/GNOME/sources/libghttp/1.0/libghttp-1.0.9.tar.gz
mv libghttp-1.0.9.tar.gz /usr/local/src

cd /usr/local/src

tar xvfz libghttp-1.0.9.tar.gz

cd libghttp-1.0.9

./configure

make

make check

make install

Expat

This installation needs a the following patch, which I assume to be saved as /tmp/XML_Status.patch:

*** lib/expat.h.orig	2003-06-30 03:51:40.000000000 +0200
--- lib/expat.h	2003-06-30 03:52:18.000000000 +0200
***************
*** 647,652 ****
--- 647,678 ----
  /* Returns the last value set by XML_SetUserData or NULL. */
  #define XML_GetUserData(parser) (*(void **)(parser))

+ /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
+    detected.  The last call to XML_Parse must have isFinal true; len
+    may be zero for this call (or any other).
+ 
+    The XML_Status enum gives the possible return values for the
+    XML_Parse and XML_ParseBuffer functions.  Though the return values
+    for these functions has always been described as a Boolean value,
+    the implementation, at least for the 1.95.x series, has always
+    returned exactly one of these values.  The preprocessor #defines
+    are included so this stanza can be added to code that still needs
+    to support older versions of Expat 1.95.x:
+ 
+    #ifndef XML_STATUS_OK
+    #define XML_STATUS_OK    1
+    #define XML_STATUS_ERROR 0
+    #endif
+ 
+    Otherwise, the #define hackery is quite ugly and would have been dropped.
+ */
+ enum XML_Status {
+   XML_STATUS_ERROR = 0,
+ #define XML_STATUS_ERROR XML_STATUS_ERROR
+   XML_STATUS_OK = 1
+ #define XML_STATUS_OK XML_STATUS_OK
+ };
+ 
  /* This is equivalent to supplying an encoding argument to
     XML_ParserCreate. On success XML_SetEncoding returns non-zero,
     zero otherwise.
***************
*** 713,744 ****
  XMLPARSEAPI(int)
  XML_GetIdAttributeIndex(XML_Parser parser);

- /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
-    detected.  The last call to XML_Parse must have isFinal true; len
-    may be zero for this call (or any other).
- 
-    The XML_Status enum gives the possible return values for the
-    XML_Parse and XML_ParseBuffer functions.  Though the return values
-    for these functions has always been described as a Boolean value,
-    the implementation, at least for the 1.95.x series, has always
-    returned exactly one of these values.  The preprocessor #defines
-    are included so this stanza can be added to code that still needs
-    to support older versions of Expat 1.95.x:
- 
-    #ifndef XML_STATUS_OK
-    #define XML_STATUS_OK    1
-    #define XML_STATUS_ERROR 0
-    #endif
- 
-    Otherwise, the #define hackery is quite ugly and would have been dropped.
- */
- enum XML_Status {
-   XML_STATUS_ERROR = 0,
- #define XML_STATUS_ERROR XML_STATUS_ERROR
-   XML_STATUS_OK = 1
- #define XML_STATUS_OK XML_STATUS_OK
- };
- 
  XMLPARSEAPI(enum XML_Status)
  XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);

--- 739,744 ----

After the patch above has been saved the rest of the Expat installation is quite simple:

cd /tmp

wget http://switch.dl.sourceforge.net/sourceforge/expat/expat-1.95.6.tar.gz
mv expat-1.95.6.tar.gz /usr/local/src

cd /usr/local/src

tar xvfz expat-1.95.6.tar.gz

cd expat-1.95.6

cp /tmp/XML_Status.patch ./XML_Status.patch

patch ./lib/expat.h < XML_Status.patch

./configure

make

make install

Sablot

Before installing Sablot and its Perl module we have to install the modules which will be needed during the next steps of the installation

perl -MCPAN -e shell
[] install XML::Parser
[] install XML::LibXML
  [XML::SAX]: Do you want XML::SAX to alter ParserDetails.ini? [Y] <enter>
[] install XML::LibXSLT

After the modules have been installed we install Sablot and the appropriate perl module.

cd /tmp

wget http://download-2.gingerall.cz/download/sablot/Sablot-0.98.tar.gz
mv Sablot-0.98.tar.gz /usr/local/src

cd /usr/local/src

tar xvfz Sablot-0.98.tar.gz

cd Sablot-0.98

export CPLUS_INCLUDE_PATH="/usr/local/include"

./configure

make

make check

make install

wget http://download-2.gingerall.cz/download/sablot/XML-Sablotron-0.98.tar.gz

tar xvfz XML-Sablotron-0.98.tar.gz

cd XML-Sablotron-0.98

perl Makefile.PL LIBS='-lstdc++ -liconv'

make

make test

make install

AxKit

The AxKit installation is very simple now. Just install some Perl modules and you are done.

perl -MCPAN -e shell
[] install Error
[] install HTTP::GHTTP
[] install XML::XPath
[] force install Apache::Test
[] force install Apache::libapreq
[] install Apache::Filter
  [Apache::Filter]: [/usr/lib/httpd/httpd] ('!' to skip): <!><enter>
[] install AxKit
[] install AxKit::XSP::Util
[] install AxKit::XSP::Param
[] install AxKit::XSP::WebUtils

After having installed alle necessary Perl modules for AxKit the last step is to setup a nice cache directory for AxKit, which will be used in our configuration later.

mkdir /opt/axkit
mkdir /opt/axkit/cache

chown nobody:nobody /opt/axkit/cache

Configuring AxKit

AxKit allow us to specify a stylesheet which is used to display errors. Maybe you find the following file useful, which I assume to be saved as /www/_shared/html/xsl/axkit_error.xsl:

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" />

<xsl:template match="/error">
<HTML>
<HEAD>
	<TITLE>AxKit error</TITLE>
</HEAD>
<BODY>
<TABLE ALIGN="center" WIDTH="100%">
	<TR>
		<TD COLSPAN="2" ALIGN="center">
   <FONT FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="-1">
    <B>AxKit error:</B>
   </FONT>
  </TD>
	</TR>
	<TR>
		<TD VALIGN="top" NOWRAP="nowrap" WIDTH="1%">
   <FONT FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="-2">
    <B>error:</B><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
   </FONT>
  </TD>
		<TD WIDTH="99%">
   <FONT FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="-2" COLOR="red">
    <xsl:value-of select="./msg" />
   </FONT>
  </TD>
 </TR>
	<TR>
		<TD VALIGN="top" NOWRAP="nowrap">
   <FONT FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="-2">
    <B>in file:</B><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
   </FONT>
  </TD>
		<TD>
   <FONT FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="-2">
    <xsl:value-of select="./file" />
   </FONT>
  </TD>
	</TR>
	<TR>
		<TD VALIGN="top" NOWRAP="nowrap">
   <FONT FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="-2">
    <B>stack-trace:</B><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
   </FONT>
  </TD>
		<TD>

  			<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">
  				<xsl:apply-templates select="./stack_trace" />		
  			</TABLE>

		</TD>
	</TR>
</TABLE>
</BODY>
</HTML>
</xsl:template>

<xsl:template match="/error/stack_trace">
	<xsl:for-each select="./bt">
		<TR>
			<TD ALIGN="right">
    <FONT FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="-2">
     <xsl:value-of select="./@level" />: 
    </FONT>
   </TD>
			<TD>
    <FONT FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="-2">
     <xsl:value-of select="./file" />:<xsl:value-of select="./line" />
    </FONT>
   </TD>
		</TR>
	</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

The last step is to configure Apache to use AxKit. The following directives should be saved in /www/httpd.conf:

#
# Setting an alias for shared files
#
Alias	/.s/	/www/_shared/html/

#
# Enabling AxKit
#
PerlModule AxKit

AxAddStyleMap text/xsl Apache::AxKit::Language::LibXSLT
AxAddStyleMap application/x-xsp Apache::AxKit::Language::XSP
AxAddStyleMap application/x-xpathscript Apache::AxKit::Language::XPathScript

PerlModule AxKit::XSP::Util
AxAddXSPTaglib AxKit::XSP::Util

PerlModule AxKit::XSP::Param
AxAddXSPTaglib AxKit::XSP::Param

PerlModule AxKit::XSP::WebUtils
AxAddXSPTaglib AxKit::XSP::WebUtils

AxCacheDir		/opt/axkit/cache
AxErrorStylesheet	text/xsl		/.s/xsl/axkit_error.xsl

PerlSetVar AxXPSInterpolate 1

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/www">

#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
    Options MultiViews FollowSymLinks Includes

#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
    AllowOverride AuthConfig

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

#
# Enabling AxKit for this directory
#
    AddHandler axkit .xml .xsp
</Directory>

Put Include /www/httpd.conf into /usr/local/apache/conf/httpd.conf to enable the configuration directives for /www and start using you apache installation by configuring your hosts.

Do not forget to restart Apache, after changing the configuration.

Congratulations. You should have a working installation of AxKit on your Red Hat 9 system now.


Edit This Page / Show Page History /