[Xapian-discuss] Apache conf.d file for omega?

Charles xapian at catcons.co.uk
Thu Dec 1 09:11:11 GMT 2011


On 28/10/11 16:30, xapian-discuss-request at lists.xapian.org wrote:
> Date: Thu, 27 Oct 2011 16:29:26 +0100
> From: James Aylett <james-xapian at tartarus.org>
> Subject: Re: [Xapian-discuss] Apache conf.d file for omega?
> To: Charles <xapian at catcons.co.uk>
> Cc: Xapian Discussion <xapian-discuss at lists.xapian.org>
> Message-ID: <BAF0BF86-82BF-450A-AED6-6B678D689C37 at tartarus.org>
> Content-Type: text/plain; charset=iso-8859-1
> 
> On 27 Oct 2011, at 15:56, Charles wrote:
> 
>> > Sorry if this question is na?ve and confused; I'm new to Apache
>> > configuration.
> We're not apache experts by any means, so you'll almost certainly be better off asking in a dedicated forum.
> 
>> > Can Apache be configured to run omega via a file in the conf.d directory
>> > rather than a virtual server?
> Yes, and probably in a number of different ways.
> 
[snip]
>> > For a conf.d file the equivalent would be an Alias directive but
>> > aliasing / would not be sane.  Is there any way to tell omega to look
>> > for the files somewhere else?
> Omega doesn't 'look' for the files anywhere, it just constructs URLs. So you need to configure the web server to serve them from somewhere.
[snip]
> J

Many thanks for your detailed and patient reply to what I now know for
sure were naive questions, James :)

The solution, using only a conf.d file (on Debian Squeeze), allows
multiple instances of directory trees searchable by omega.  Each
instance has:

* its own directory tree.
* its own omega.conf file and so its own database and templates.
* can run a different version of omega.

The file and directory structure used:

/etc/opt/docoll/<instance>/search/ to configure docoll's Omega usage.
Has omega.conf and the templates sub-directory.

/srv/docoll/<instance>/ for the tree, indexed by omindex.

/usr/lib/cgi-bin/omega/ for the omega CGI executable.  If more than one
version of it is installed, the non-default version in
/usr/lib/cgi-bin/omega/<version>/

/var/opt/docoll/omega/<instance>/ for the Xapian index of
/srv/docoll/<instance> files.

/var/www/docoll/<instance>/, an empty directory for Apache to rewrite to
an omega call.

/var/www/docoll/<instance>/hits for omega to generate links to.
Symlinked to /srv/docoll/<instance>.  Allows the tree to be outside
Apache's DocumentRoot.

The conf.d file:

<Directory /var/www/docoll>
    # Ensure required settings in case defaults have been changed
    [snip]

    RewriteEngine  On
    RewriteBase    /
    RewriteRule    ^/*$ /cgi-bin/omega/omega?DB=default&FMT=docoll [L]
    RewriteRule    ^omega-(1.0.23)$
/cgi-bin/omega/$1/omega?DB=default&FMT=docoll [L]
    RewriteRule    ^([^/]*)/*$ /cgi-bin/omega/omega?DB=$1&FMT=docoll [L]
</Directory>

<Directory /usr/lib/cgi-bin/omega>
    # Ensure required settings in case defaults have been changed
    [snip]

    RewriteEngine  On
    RewriteBase    /
    RewriteCond    %{QUERY_STRING} (&|^)DB=([^&]*)&
    RewriteRule    .* -
[env=OMEGA_CONFIG_FILE:/etc/opt/docoll/%2/search/omega.conf] [L]
</Directory>

Explanation ...

First the default case ...

For a clean user interface, the user can access the default instance by
browsing http://<server ID>/docoll.  This matches the first RewriteRule
so calls /cgi-bin/omega/omega with DB=default&FMT=docoll (docoll is a
lightly modified version of the query template).  The RewriteCond
extracts the DB value (in this case "default") and uses it to set
environment variable OMEGA_CONFIG_FILE to the instance-specific omega.conf.

omega.conf sets the default database and templates directories.

The docoll template is generic but includes an instance-specific config
file with:
$set{docoll_hits_dir,/docoll/default/hits}

The docoll_hits_dir variable is used to prefix hit URLs with
/docoll/<instance>/hits so Apache follows the symlink and serves from
/srv/docoll/<instance>/ (where omindex indexed the files from).

Now the non-default case ...

For a non-default instance the user browses http://<server
ID>/docoll/<instance>.  The third RewriteRule extracts the instance name
and uses it for the DB name.  The remaining process is very similar to
the default case.

For a different version of Omega and the default tree ...

The user browses for example http://<server ID>/docoll/omega-1.0.23.
The second RewriteRule calls /cgi-bin/omega/1.0.23/omega.  The scheme
could be extended to other trees.

Best

Charles





More information about the Xapian-discuss mailing list