Skip to content
zc.buildout recipe for mod_wsgi based deployments
Find file
Latest commit 26fb20e @wichert Onwards
Failed to load latest commit information.
collective Handle broken symlinks when using the target option
docs Onwards
.gitignore Add some ignores. 1.5 had a broken MANIFEST, redo as 1.6.
README.rst Onwards



''collective.recipe.modwsgi'' is a zc.buildout recipe which creates a paste.deploy entry point for mod_wsgi.

It is very simple to use. This is a minimal ''buildout.cfg'' file which creates a WSGI script mod_python can use:

parts = mywsgiapp

recipe = collective.recipe.modwsgi
eggs = mywsgiapp
config-file = ${buildout:directory}/production.ini

This will create a small python script in parts/mywsgiapp called ''wsgi'' which mod_wsgi can load. You can also use the optional ''extra-paths'' option to specify extra paths that are added to the python system path.

The apache configuration for this buildout looks like this:

WSGIScriptAlias /mysite /home/me/buildout/parts/mywsgiapp/wsgi

<Directory /home/me/buildout>
    Order deny,allow
    Allow from all

If the python script must be accessed from somewhere else than the buildout parts folder, you can use the optional ''target'' option to tell the recipe where the script should be created.

For instance, the configuration for the mywsgiapp part could look like this:

recipe = collective.recipe.modwsgi
eggs = mywsgiapp
target = /var/www/myapp.wsgi
config-file = ${buildout:directory}/production.ini

The recipe would then create the script at /var/www/myapp.wsgi.

Note that the directory containing the target script must already exist on the filesystem prior to running the recipe and be writeable.

The apache configuration for this buildout would then look like this:

WSGIScriptAlias /mysite /var/www/myapp.wsgi

<Directory /var/www>
    Order deny,allow
    Allow from all

This recipe does not fully install packages, which means that console scripts will not be created. If you need console scripts you can add a second buildout part which uses z3c.recipe.scripts to do a full install.

Configuration files with multiple applications

It is possible to specify multiple applications or pipelines in a single configuration file. If you do this you can specify which application to run by using the app_name option. For example if your ini files looks like this:

use = egg:my_application

pipeline = my_app

pipeline =

This specifies two way to run the your application: a production configuration which runs the application directly, and a devel configuration which also runs the WebError interactive debugger to catch errors. To use the production pipeline in mod_wsgi supply the app_name parameter:

recipe = collective.recipe.modwsgi
eggs = mywsgiapp
app_name = production
config-file = ${buildout:directory}/production.ini
Something went wrong with that request. Please try again.