Thursday, November 22, 2012

Create a Wiki (Moinmoin) on Raspberry

Moinmoin is a very good Wiki application without using a DB. It is very fast, with easy syntax and I recommend to use it as a quick knowledge base for home or SME usage.

 This guide is to install moinmoin on a Raspberry Pi and make it accessible via Lighttpd (using fastcgi). It is assumed a virtual host is available for this wiki (eg. http://wiki.example.com )
The moinmoin program will be installed at /usr/local/moinmoin_engine while the instance will be installed at another place (eg. /usr/local/moinmoin_instance1. )
  1. Download the latest source (1.9.5 as of this moment) at http://moinmo.in
  2. extract the tar ball to a temp place (eg. /tmp)
  3. under the source path, run
    python setup.py install --prefix=/usr/local/moinmoin_engine
  4. mkdir the instance path
    mkdir /usr/local/moinmoin_instance1
  5. copy the following directories from "engine" to "instance", and change the ownership to the lighttpd user:
    cp -r /usr/local/moinmoin_engine/share/moin/data /usr/local/moinmoin_instance1
    cp -r /usr/local/moinmoin_engine/share/moin/underlay /usr/local/moinmoin_instance1
    cp /usr/local/moinmoin_engine/share/moin/config/wikiconfig.py /usr/local/moinmoin_instance1
    cp /usr/local/moinmoin_engine/share/moin/server/moin.fcgi /usr/local/moinmoin_instance1
    chown -R www-data:www-data /usr/local/moinmoin_instance1
  6. modify the moin.fcgi, locate the following lines:
    # a1) Path of the directory where the MoinMoin code package is located.
    #     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
    #sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
    sys.path.insert(0, '/usr/local/moinmoin_engine/lib/python2.7/site-packages')
    
    # a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
    #     See wiki/config/... for some sample config files.
    #sys.path.insert(0, '/path/to/wikiconfigdir')
    sys.path.insert(0, '/usr/local/moinmoin_instance1')
    
    ...
    
    ## this works around a bug in flup's CGI autodetection (as of flup 1.0.1):
    #os.environ['FCGI_FORCE_CGI'] = 'Y' # 'Y' for (slow) CGI, 'N' for FCGI
    os.environ['FCGI_FORCE_CGI'] = 'N'
    
    ...
    
    # Is fixing the script name needed?
    # Use None if your url looks like http://domain/wiki/moin.fcgi
    # Use '' if you use rewriting to run at http://domain/
    # Use '/mywiki' if you use rewriting to run at http://domain/mywiki/
    #fix_script_name = None  # <-- adapt="adapt" as="as" class="anchor" here="here" id="line-24" needed="needed" span="span">
fix_script_name = ''# <-- adapt="adapt" as="as" here="here" needed="needed" pre="pre">
  • Next prepare virtual host by appending the following block /etc/lighttpd/lighttpd.conf:
    $HTTP["host"] =~ "wiki\.example\.com" {
            
      fastcgi.server += ( "/" =>
          ((
            "socket" => "/tmp/moin.socket",
            "min-procs" => 1,
            "max-procs" => 2,
            "check-local" => "disable",
            "bin-path" => "/usr/local/moinmoin_instance1/moin.fcgi",
            "fix-root-scriptname" => "enable"
          ))
      )
    
      alias.url += ( "/moin_static195" => "/usr/local/moinmoin_engine/lib/python2.7/site-packages/MoinMoin/web/static/htdocs")
    
    }
  • Restart Lighttpd and the your own wiki is just born! 

  • For more information about user and administration guide, please refer the HelpContents.

    PS: So here is the wiki running on my Raspberry Pi: http://wiki.jessed121.us/ . You can walk around and feel it.

    5 comments:

    Jeff Wolach said...

    Nice tutorial. I have one question though. Do you have or can you post a quick tutorial on creating the virtual host for the wiki on the Raspberry Pi?

    Poor IT Guy said...

    Thanks for your comment. I'm not sure I understand your question completely. But I can explain the virtual host in lighttpd in brief.

    In lighttpd, the virtual host by domain name is just using $HTTP["host"] block to handle. For example, if there is "www.example1.com" and "www.example2.com" in the same server, you can create two blocks in lighttpd.conf:

    $HTTP["host"]=~"www\.example1\.com"{
    server.document-root=""
    ...
    }

    $HTTP["host"]=~"www\.example2\.com"{
    server.document-root=""
    ...
    }

    Jeff Wolach said...

    I'm not sure what I'm doing wrong. Here's my lighttpd.conf file. I think I have the virtual host block for my wiki correct. However, when I go to the URL for the wiki, it just pulls up the default Lighttpd index page.

    server.modules = (
    "mod_access",
    "mod_alias",
    "mod_compress",
    "mod_redirect",
    # "mod_rewrite",
    )

    server.document-root = "/var/www"
    server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
    server.errorlog = "/var/log/lighttpd/error.log"
    server.pid-file = "/var/run/lighttpd.pid"
    server.username = "www-data"
    server.groupname = "www-data"
    server.port = 80

    index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
    url.access-deny = ( "~", ".inc" )
    static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

    compress.cache-dir = "/var/cache/lighttpd/compress/"
    compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )

    # default listening port for IPv6 falls back to the IPv4 port
    include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
    include_shell "/usr/share/lighttpd/create-mime.assign.pl"
    include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

    $HTTP["host"] =~ "wiki\.lab\.kd-group\.com" {

    fastcgi.server += ( "/" =>
    ((
    "socket" => "/tmp/moin.socket",
    "min-procs" => 1,
    "max-procs" => 2,
    "check-local" => "disable",
    "bin-path" => "/usr/local/moinmoin_instance1/moin.fcgi",
    "fix-root-scriptname" => "enable"
    ))
    )

    alias.url += ( "/moin_static195" => "/usr/local/moinmoin_engine/lib/python2.7/site-packages/MoinMoin/web/static/htdocs")

    }

    Lost in my life said...

    Hi!
    I´m also trying to create a personal wiki on a small linux server. As I just have 512mb of memory, I would like to do it with lighttpd & moinmoin. But as the other guy that comment before, I just get the default page as result.. I have the same conf file, just changing the host url. Any idea?

    Poor IT Guy said...

    hm...
    first of all, make sure the process "/moin.fcgi" is running.

    next is to check the virtual hosting is working fine for lighttpd