After we have set up our Ikiwiki myiki in the first part of this series we are now enabling the search function.

The search functionality is based on xapian-omega and provides full text search and some advanced features known from other search engines.

Xapian allows for incremental updates of the search index and has many more features.

The search function is provided by ikiwiki.cgi and thus requires cgi-support on the web server.– install required Xapian packages

    # apt-get install libsearch-xapian-perl xapian-omega
  • add search to the add_plugins:-section in myiki.setup

      - goodstuff
      - websetup
      - theme
      - search
  • rebuild the wiki. This step is required only once, in normal operation the wiki is updated with a post_receive git-hook (technically that does a refresh of ikiwiki, just updating changed pages and pages affected by these changes).

      $ ikiwiki -setup ~/myiki.setup rebuild
  • re-configure apache to allow cgi-execution on user dirs, the Ikiwiki CGI is named ikiwiki.cgi by default. (Note: for security reasons this may not be the best choice in a multi-user production environment)

      # diff -u /etc/apache2/mods-available/ /etc/apache2/mods-available/userdir.conf
      --- /etc/apache2/mods-available/        2014-07-25 19:28:21.644032192 +0400
      +++ /etc/apache2/mods-available/userdir.conf    2014-07-25 19:29:48.448030222 +0400
      @@ -3,8 +3,9 @@
               UserDir disabled root
               <Directory /home/*/public_html>
      +               AddHandler cgi-script .cgi
                       AllowOverride FileInfo AuthConfig Limit Indexes
      -                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
      +                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec +ExecCGI
                       <Limit GET POST OPTIONS>
                               Order allow,deny
                               Allow from all

    and do not forget to restart apache (service apache2 restart or /etc/init.d/apache2 restart).

  • on the next (re-) load the myiki-page shows a “search”-field in the upper right corner.

Search has some additional features like phrase matching with quoting, AND/OR expressions, searching for links and titles, … see searching (or your local version of that page searching) for all details.

Other Ikiwiki articles.