Why use mod_wsgi?

mod_wsgi is written directly to the internal Apache and Python application programming interfaces. As such, running Moin on Apache with mod_wsgi, Apache uses less memory and performs better than existing accelerators such as FastCGI, mod_python, or other proxy-based solutions.

See the mod_wsgi homepage for details.

Getting Started

It is recommended to first set up and configure Moin with Apache using standard CGI (see HelpOnInstalling). Test and make sure everything works, then change the configuration to use mod_wsgi. This allows you be sure that any problems are in the mod_wsgi transition rather than the basic MoinMoin installation.

The sample configurations below are for a wiki instance called mywiki installed in a directory /var/www/moin/mywiki with the main MoinMoin installation installed in python's default site library path. The wiki appears as URL /mywiki under the server - ie http://server.example.com/mywiki. You will need to change these to reflect your installation.

Download & Install mod_wsgi

  1. Download the most current release that matches your Apache version, as linked from the mod_wsgi homepage.

  2. install the mod_wsgi module into your Apache/modules directory
    1. Linux users will likely need to build from source (which is rather easy, assuming you have a development environment installed).
    2. Windows users will need to grab the pre-compiled binary from the mod_wsgi website.
  3. Modify your Apache httpd.conf file, to add the following line:

    LoadModule wsgi_module modules/mod_wsgi.so
  4. Restart Apache. Make sure it starts successfully, and check the error log for any errors.

Modify Apache's configuration file

After your wiki is running as cgi script, convert it to run with mod_wsgi.

If you run your wiki as cgi as we recommended before, remove or comment the ScriptAlias directive:

#ScriptAlias /mywiki "/var/www/moin/mywiki/moin.cgi"

Add this to the same virtualhost definition:

    ## this is the URL http://server.example.com/mywiki/ you will use to invoke moin:
    WSGIScriptAlias /mywiki /var/www/moin/mywiki/moin.wsgi

    ## in case you want your wiki under the root url (http://server.example.com/), use this instead:
    #Alias /robots.txt /usr/share/moin/htdocs/robots.txt
    #Alias /favicon.ico /usr/share/moin/htdocs/favicon.ico
    #WSGIScriptAlias / /var/www/moin/mywiki/moin.wsgi

    ## Linux-only (Windows users, please ignore): 
    ## uncomment & create some wsgi daemons - use someuser.somegroup same as your data_dir :
    #WSGIDaemonProcess moin user=someuser group=somegroup home=/home/someuser processes=5 threads=10 maximum-requests=1000 umask=0007


    ## Linux-only (Windows users, please ignore): 
    ## for mod_wsgi >= 2.0: uncomment & append this to have a nice ps aux display:
    # display-name=wsgi-moin

    ## Linux-only (Windows users, please ignore): 
    ## uncomment & use the daemons we defined above to process requests!
    #WSGIProcessGroup moin

    ## This is required if you plan to use HTTP authorization. Without it the user name won't
    ## be passed to MoinMoin. 
    #WSGIPassAuthorization On

Edit moin.wsgi

Please also have a look into moin.wsgi - you maybe have to change some sys.path.insert instructions so Python can find the MoinMoin code and the wiki configuration. On Windows, you may have to add:

sys.path.insert(0, 'd:\path\to\moin')

Finished!

Restart Apache - everything should now work correctly.

In the future to reload any new configuration changes, restart the wsgi daemon. Windows users, you will have to stop & restart the Apache2 service in the Services control panel (under Administrative Tools).

MoinMoin Appliance - Powered by TurnKey Linux