MoinMoin On Dreamhost

This article shows how to install MoinMoin on Dreamhost.

Installation

  • Download Moin:

    $ wget http://static.moinmo.in/files/moin-1.9.3.tar.gz
  • Extract files:

    $ tar xvzf moin-1.9.3.tar.gz
  • Install to local home directory:

    $ cd moin-1.9.3
    $ python setup.py --quiet install --prefix=~ --record=install.log
  • Create a wiki instance:

    $ mkdir ~/wiki
    $ cd ~/wiki
    $ ln -s ~/lib/python2.5/site-packages/MoinMoin/web/static/htdocs .
    $ ln -s ~/share/moin/underlay .
    $ cp -r ~/share/moin/data .
    $ cp ~/share/moin/server/moin.cgi .
    $ cp ~/share/moin/config/wikiconfig.py .
  • Create ~/wiki/.htaccess file with contents:

    AddHandler cgi-script .cgi
    Options FollowSymLinks ExecCGI
    DirectoryIndex moin.cgi
    
    # start the rewrite engine
    RewriteEngine On
    RewriteBase /wiki
    
    RewriteRule ^htdocs/ - [L]
    RewriteRule ^moin.cgi - [L]
    
    # If you want to hide the moin.cgi from the URLs, in moin.cgi
    # replace the line that says
    #     properties = {}
    # for a line like this one:
    #     properties = {'script_name':'/'})
    # and uncomment the following line
    RewriteRule ^(.*) moin.cgi/$1 [T=application/x-httpd-cgi]
  • Set the appropriate permissions:

    $ chmod 644 ~/wiki/wikiconfig.py
    $ chmod 755 ~/wiki/moin.cgi
    $ chmod 644 ~/wiki/.htaccess
    $ chmod -R u+rwX ~/wiki/data
    $ chmod -R go-w ~/wiki/data
  • Change ~/wiki/moin.cgi with the following patch:

    --- /home/zhigang/share/moin/server/moin.cgi    2009-06-09 12:49:49.000000000 -0700
    +++ /home/zhigang/wiki/moin.cgi 2009-08-09 19:51:24.000000000 -0700
    @@ -1,4 +1,4 @@
    -#!/usr/bin/env python
    +#!/usr/bin/python2.5
     # -*- coding: iso-8859-1 -*-
     """
         MoinMoin - CGI Driver Script
    @@ -17,11 +17,13 @@ import sys, os
     # 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, '/home/zhigang/lib/python2.5/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, '/path/to/farmconfigdir')
    +sys.path.insert(0, '/home/zhigang/wiki')
    
     # b) Configuration of moin's logging
     #    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
    @@ -44,6 +46,7 @@ class Config(CgiConfig):
         # Allow overriding any request property by the value defined in
         # this dict e.g properties = {'script_name': '/mywiki'}.
         ## properties = {}
    +    properties= {'script_name': '/wiki'}
    
         # Hotshot profile (default commented)
         ## hotshotProfile = name + '.prof'
  • Make a link to the new wiki directory:

    $ cd ~/zhigang.org
    $ ln -s ../wiki .
  • Change ~/zhigang.org/.htaccess to allow access of the wiki with the following patch:

    --- .htaccess.orig      2008-12-29 08:09:07.000000000 -0800
    +++ .htaccess   2008-12-29 05:14:45.000000000 -0800
    @@ -99,6 +99,10 @@ DirectoryIndex index.php
       RewriteEngine On
       RewriteBase /
    
    +  # Enable wiki
    +  RewriteCond %{REQUEST_URI} ^/wiki/(.*)$
    +  RewriteRule ^.*$ - [L]
    +
       # Enable stats
       RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
       RewriteCond %{REQUEST_URI} ^/failed_auth.html$
  • Language setup: http://zhigang.org/wiki/LanguageSetup?action=language_setup&pageset=all_pages&language=English

  • Testing: http://zhigang.org/wiki/

Optimization

Common CGI is pretty slow in Dreamhost. Instead, we can use FastCGI.

  • Enable FastCGI for your site in Dreamhost Control Panel: https://panel.dreamhost.com/

  • Copy script:

    $ cd ~/wiki
    $ cp ~/share/moin/server/moin.fcg moin.fcgi
    $ chmod 755 moin.fcgi

    Note

    You must change the extension from "fcg" to "fcgi".

  • Make necessary changes as for moin.cgi.

  • Replace the contents of ~/wiki/.htaccess with:

    AddHandler fastcgi-script .fcgi
    Options FollowSymLinks ExecCGI
    DirectoryIndex moin.fcgi
    
    # start the rewrite engine
    RewriteEngine On
    RewriteBase /wiki
    
    RewriteRule ^htdocs/ - [L]
    RewriteRule ^moin.fcgi - [L]
    
    # If you want to hide the moin.cgi from the URLs, in moin.fcgi
    # replace the line that says
    #     properties = {}
    # for a line like this one:
    #     properties = {'script_name':'/'})
    # and uncomment the following line
    RewriteRule ^(.*) moin.fcgi/$1 [T=application/x-httpd-fcgi]
  • Test the wiki: http://zhigang.org/wiki/ or http://zhigang.org/wiki/moin.fcgi

Add Advertisement

To add Google Adsense to your site, just add the ad code to the "page_footer1" (or other variables) in wikiconfig.py. Eg:

# Add advertisement
page_footer1 = '''<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-5285936463757055";
/* 728x90, created 1/1/09 */
google_ad_slot = "9618510425";
google_ad_width = 728;
google_ad_height = 90;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>'''

None: MoinOnDreamhost (last edited 2011-06-08 03:36:19 by ZhigangWang)