<section id="installation">
    <title>Apache Rivet Installation</title>
    <procedure>
        <para> 
            Rivet 2.1 runs with the Apache 2.2.x and 2.4.x HTTP web server. 
            It is known to build and run on various Linux distributions 
            (Debian &amp; Ubuntu, Redhat, SuSE and CentOS), FreeBSD and OpenBSD. For some
            of these Unix-like operative systems 
            <ulink url="http://tcl.apache.org/rivet/static/download.html">binary packages</ulink> 
            are already available for download.
        </para>
        <para>
            Currently there is no way to run Apache Rivet 2.1 on Windows&copy; because            
            Rivet currently requires the 
            <ulink url="http://httpd.apache.org/docs/2.2/mod/prefork.html">prefork</ulink>, which
            is supported only on Unix/Linux systems. Efforts are under way to extend the support to the 
            <ulink url="http://httpd.apache.org/docs/2.2/mod/worker.html">worker</ulink> 
            and the
            <ulink url="http://httpd.apache.org/docs/2.2/mod/mpm_winnt.html">winnt</ulink> MPMs.
            Check our
            <ulink url="http://tcl.apache.org/rivet/static/about.html">development mailing list</ulink>
            for the latests updates about Rivet development
        </para>
        <para>
            If you need to compile Apache Rivet yourself this is the procedure to follow
        </para>
        <step performance="required">
            <title>Install Tcl</title>
            <para>
                Installing Rivet is about endowing the Apache HTTP webserver with the ability
                of running scripts written with the Tcl programming language. 
                Therefore the 
                <ulink url="http://www.tcl.tk/">Tcl</ulink> 
                shell (<command>tclsh</command>), its runtime and  
                development libraries (&ge;8.5.10) have to be installed. Building Rivet you will 
                have to tell the scripts where the Tcl libraries are located via the
                <option>--with-tcl</option> option to <command>configure</command> (see below).
            </para>
			</step>
         <step>
            <title>Get Rivet</title>
            <para>
                Download the sources at <ulink url="http://tcl.apache.org/rivet/static/download.html"/>.  
            </para>
         </step>
         <step performance="optional">
            <title>Get and Install Apache Sources</title>
            <para>
                Rivet needs some of the include (.h) files shipped with the webserver source code. 
                The easiest way to get them is to download the Apache source.  
                If can build Rivet either statically (compiled into the Apache web
                server instead of loaded dynamically) or dynamically (as a loadable shared library).  
                We recommend that you build Rivet as a shared library, for maximum flexibility,
                meaning that you also build Apache to be able to load modules. Other than that, 
                the default Apache install is fine.  We will tell Rivet where it is located via the 
                <option>--with-apxs</option> option to <command>configure</command> (see below).
            </para>
            <para>
                The source code for the Apache web server may be found by following the links here: 
                <ulink url="http://httpd.apache.org/"/>.
            </para>
          </step>
          <step>
            <title>Uncompress Sources</title>
            <para>
              We will assume that you have Apache installed at this point.
              You must uncompress the Rivet sources in the directory where you
              wish to compile them.
              <programlisting>gunzip rivet-X.X.X.tar.gz
tar -xvf rivet-X.X.X.tar.gz</programlisting>
            </para>
          </step>
      <step>
	<title>Building Rivet</title>
	<substeps>
	  <step>
	    <para>
	      On Linux or Unix systems, Rivet uses the standard <command>./configure ; make ; make install
	      (; make install-packages)</command>
	      sequence.
	    </para>
	    <para>
	      There are several rivet specific options to configure that might be useful (or needed):
	      <variablelist>
		<varlistentry>
		  <term>--with-tcl</term>
		  <listitem>
		    <para>
		      This points to the directory where the
		      <filename>tclConfig.sh</filename> file is located.
		    </para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>--with-tclsh</term>
		  <listitem>
		    <para>This points to the location of the
		      <filename>tclsh</filename> executable.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>--with-apxs</term>
		  <listitem>
		    <para>The location of the <filename>apxs</filename>
		      program that provides information about the
		      configuration and compilation options of Apache modules.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>--with-apache-version=[1|2]</term>
		  <listitem>
		    <para>
			This option tells the build scripts whether you want to build Rivet for the
			Apache 1.x or Apache 2.x server. (Obsolete: Apache 1.x is no longer supported)
		    </para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>--with-apache-include[=DIR]</term>
		  <listitem>
		    <para>
			    Locates the Apache include files on your computer, if they're not in standard directory. 
		    </para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>--enable-version-display=[yes|no]</term>
		  <listitem>
		    <para>
			This option enables Rivet to display its version in the logfiles when Apache is started. 
			The default is to keep Rivet version hidden.
		    </para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		    <term>--with-rivet-target-dir=DIR</term>
		    <listitem>
			<para>
			    This option tells the install script where Rivet's Tcl packages have to be copied. 
			</para>
		    </listitem>
		</varlistentry>
		<varlistentry>
		    <term>--with-upload-dir=DIR</term>
		    <listitem>
		      <para>
		          Configures Rivet's default upload directory 
		      </para>
		    </listitem>
		</varlistentry>
		<varlistentry>
		    <term>--enable-head-requests</term>
		    <listitem>
		      <para>
		          By default HEAD requests don't go through the usual request processing which leads
		          to script execution and therefore resource consumption and Rivet returns a
		          standard hardcoded HTML header to save CPU time. --enable-head-requests
		          changes this default (see also <link linkend="directives">Rivet Directives</link>)
		      </para>
		    </listitem>
		</varlistentry>
		<varlistentry>
		    <term>--disable-rivet-commands-export</term>
		    <listitem>
		      <para>
		          By default Rivet's commands are put on the export list of the <code>::rivet</code>
		          namespace. With this option you may prevent it thus forcing the programmer to
		          fully qualify <link linkend="commands">these commands</link>
		      </para>
		    </listitem>
		</varlistentry>
		<varlistentry>
		    <term>--disable-import-rivet-commands</term>
		    <listitem>
		      <para>
		          Likewise commands in the Rivet's namespace when exported are then by default imported
		          into the global namespace for compatibility with previous version of Rivet.
		          (Enabling the import of Rivet's commands overrides the switch --disable-rivet-commands-export
		          and forces the export from <code>::rivet</code>). This switch overrides the default and
		          prevents the import into the global namespace 
		      </para>
		    </listitem>
		</varlistentry>
		
	      </variablelist>
	    </para>
	    <para>
		  Example: configuring the build system to compile Rivet for an apache 2.x server, using tcl8.5 and
		  specifying a custom name for the apxs program. 
	    </para>
	<programlisting>./configure --with-tcl=/usr/lib/tcl8.5/ --with-tclsh=/usr/bin/tclsh8.5 \
	    --with-apxs=/usr/bin/apxs2 --with-apache=/usr --with-apache-version=2</programlisting>
	  </step>
	  <step>
	    <title>Run make</title>
	    <para>
	      At this point, you are ready to run make, which should
	      run to completion without any errors (a warning or two
	      is ok, generally).
	    </para>
	  </step>
	  <step>
	    <title>Install</title>
	    <para>
	      Now, you are ready to run the
	    </para>
	    <programlisting>make install</programlisting>
	    <para> 
	       to install the resulting files. The <code>install</code> target
	       actually fires the <code>install-binaries</code> and 
	       <code>install-packages</code> targets which in turn 
	       copy the binary modules and Tcl packages to their destination
	       directories. This commands create a functional Rivet environment with its
		   core language.
	    </para>
	  </step>
	</substeps>
      </step>
      <step>
	<title>Apache Configuration Files</title>
	<para>
	  Rivet is relatively easy to configure - we start off by
	  adding the module itself:
	</para>

	<programlisting>LoadModule rivet_module	<replaceable>/usr/lib/apache2/modules/mod_rivet.so</replaceable></programlisting>

	<para>
	  This tells Apache to load the Rivet shared object, wherever
	  it happens to reside on your file system.  Now we have to
	  tell Apache what kind of files are "Rivet" files and how to
	  process them:
	</para>

	<programlisting>AddType application/x-httpd-rivet .rvt
AddType application/x-rivet-tcl .tcl</programlisting>

	<para>
	  These tell Apache to process files with the
	  <filename>.rvt</filename> and <filename>.tcl</filename>
	  extensions as Rivet files.
	</para>
	<para>
	  The characters encoding can be changed using the <command>header type</command> command,
	  but you can also change the default charset for the whole site:
	</para>
	<programlisting>AddType 'application/x-httpd-rivet;charset=utf-8' rvt</programlisting>
	<para>
	   All the pages generated by Rivet on this site will be sent with a 
	    <command>Content-Type:'text/html;charset=utf-8'</command> header.
	</para>
	<para>You may also wish to use Rivet files as index files for
	directories.  In that case, you would do the following:</para>
	<programlisting>DirectoryIndex index.html index.htm index.shtml index.cgi index.tcl index.rvt</programlisting>
	<para>
	  For other directives that Rivet provides for Apache
	  configuration, please see <xref linkend="directives"/>.
	</para>
      </step>
    </procedure>
</section>

