Using MoinMoin with apache + mod_fastcgi
FastCGI is a method which enables apache to communicate with long-running scripts. This has the advantage that the script is only started and initialized one time, and that data could be cached in memory from request to request, enhancing the performance of the CGI application.
Deploying MoinMoin with apache + mod_fastcgi
To deploy MoinMoin using FastCGI you need an apache with mod_fastcgi. Please refer to the documentation of mod_fastcgi how to build it.
Follow the basic apache installation for your operating system as described in other parts of the MoinMoin installation documentation. In places where the documentation refers to moin.cgi you use moin.fcg instead. Be sure that .fcg is handled by the FastCGI module (AddHandler fastcgi-script .fcg in your apache config).
Normally apache will start CGI scripts with its own user and group, or with the user and group of the VirtualHost if you are using the suexec wrapper. To enable this with FastCGI you need to use FastCgiWrapper On in your apache config (see FastCGI Documentation).
Be sure to restart your apache after you changed py files (i.e. the config) for a running FastCGI server, or you won't see any changes!
Running as an external application and/or on Windows
Experimental.
MoinMoin can be run as an external application that answers FastCGI request via a local TCP/IP socket. This works on Windows as well. All you need to do (after having installed mod_fastcgi and a working MoinMoin instance) is this:
- Select a port number for the internal communication. It should be larger than 1023. For this example, we chose 8888 (just for fun).
Add the following lines to your httpd.conf:
Alias /moin.fcg "/your/path/to/moin.fcg" FastCgiExternalServer "/your/path/to/moin.fcg" -host localhost:8888
Edit moin.fcg. Replace
fcg = thfcgi.THFCGI(handle_request)
with
fcg = thfcgi.THFCGI(handle_request, 0, 8888)
Start the file moin.fcg manually like a Python script:
python moin.fcg
- Start Apache.
Enjoy MoinMoin running with FastCGI support!
Add a safe fallback
Install and test MoinMoin according to HelpOnInstalling/ApacheOnLinux. Then make and test the changes to run mod_fastcgi. If you are satisfied, you can add the following block to your apache config:
<IfModule !mod_fastcgi.c> ScriptAlias /mywiki "/your/path/to/moin.cgi" </IfModule> <IfModule mod_fastcgi.c> AddHandler fastcgi-script .fcg ScriptAlias /mywiki "/your/path/to/moin.fcg" </IfModule>
Now Apache will use mod_fastcgi if available and otherwise use the slow cgi script.