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.

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

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

install the mod_wsgi module into your Apache/modules directory

Linux users will likely need to build from source (which is rather easy, assuming you have a development environment installed).

Windows users will need to grab the pre-compiled binary from the mod_wsgi website.

Modify your Apache httpd.conf file, to add the following line:

LoadModule wsgi_module modules/mod_wsgi.so

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:

Linux users: Please note that "daemon mode" is an optional, but perhaps preferred way to use mod_wsgi. Daemon-mode allows you to relaunch just mod_wsgi to pick up configuration changes, instead of having to relaunch the Apache server. This is useful if your web server is hosting other sites, for example. See mod_wsgi configuration guide for detailed explanation. To implement, note the additional optional directives in the example below.

Windows users: daemon mode does not work under Windows, and so does not apply. You will need to stop & start the Apache2 service to pick up new configuration changes.

Copy and edit moin.wsgi

Copy moin.wsgi to /var/www/moin/mywiki/ and then edit it there - you maybe have to change some sys.path.insert instructions so Python can find the MoinMoin code and the wiki configuration, see the instructions in moin.wsgi.