how to use WSGI applications with apache

Paul Rudin paul.nospam at rudin.co.uk
Wed Oct 7 11:16:10 CEST 2009


travis+ml-python at subspacefield.org writes:

> Hi folks,
>
> I'm not quite sure where to ask this, but this is my closest guess.
>
> I've written a web service based on the newf micro-framework and it uses
> wsgiref.simple_server.  I'm noticing that it's not returning response
> codes properly (after fixing a bug in newf).  Instead, it just
> closes the TCP connection silently.
>
> I am assuming that I need to run it with a more sophisticated server,
> and I eventually want to run it under apache, but I can't seem to
> figure out how to do this.  Someone once showed me how, and it was
> a simple line in the apache config.  But I can't figure it out how
> to do again.
>
> Any help?

There are all manner of things that you can configure. First you need to
enable mod_wsgi - on as linux box this should be something like:
"a2enmod wsgi"

Then you need something like this inside a suitable virtualhost tag in
your apache configuration files:


WSGIDaemonProcess test threads=1 processes=1 maximum-requests=10000 \
   python-path=/dir/for/my/script

WSGIProcessGroup test

WSGIScriptAlias /test /dir/for/my/script/myscript.wsgi

<Directory /dir/for/my/script>
  Order allow,deny
  Allow from all
</Directory>


The file myscript.wsgi is a python module within which  "application"
names your wsgi application.



More information about the Python-list mailing list