Some of the information here may be outdated, please check the book instead

Here is an over-simplified recipe for setting up mod_wsgi with web2py on CentOS 5. See the Web2py manual for the authoritative specification of how to configure mod_wsgi in general.

Install Apache and the development package (to get the apxs program needed by mod_wsgi);

sudo yum install httpd httpd-devel

Get the mod_wsgi source and build it:

cd /usr/local/src
tar xzvf mod_wsgi-2.5.tar.gz
cd mod_wsgi-2.5
configure  --with-python=/usr/local/bin/python2.5
sudo make install

Edit /etc/httpd/conf/httpd.conf to load modules/ and to point to the right python instance:

LoadModule wsgi_module modules/

Create /etc/httpd/conf.d/web2py.conf with this (which assumes web2py is installed in /var/local/web2py/, and web2py is the root of the Apache site):

WSGIScriptAlias / /var/local/web2py/

Note that the web2py folders need to be writable by the apache process.

Running as a mod_wsgi daemon process

The above sets up mod_wsgi in "embedded" mode. To run as a mod_wsgi daemon, add this to web2py.conf:

WSGIDaemonProcess web2py

and put this right below the WSGIScriptAlias line:

WSGIProcessGroup web2py

I also had to make a /var/www/.python-eggs directory that is writable by the apache process; otherwise the MySQLdb module would not import into web2py.

Finally, I had to disable mod_mem_cache in apache to get around errors like this: "SystemError: NULL result without error in PyObject_Call". But when I enable that again later I no longer see the errors. Confusing.

(Edits: No longer recommending WSGIPythonHome. Use --with-python when configuring mod_wsgi.)


© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.