[Grok-dev] Grok 1.0a1 under Apache+mod_wsgi

Santiago Videla santiago.videla at gmail.com
Sun Feb 15 11:40:30 EST 2009


Hey,

Well, here is what I did. I'm not a very good tutorials writer (and my
English it's a little bit poor...), so maybe Uli or somebody else could
re-write this to publish it on grok.zope.org. Or we can just wait, until
grokproject take care of whole story. :)

All seems to work fine, but I'm getting an error in the apache logs:

[Sun Feb 15 14:04:55 2009] [error] Traceback (most recent call last):
[Sun Feb 15 14:04:55 2009] [error]   File
"/usr/lib/python2.5/logging/__init__.py", line 750, in emit
[Sun Feb 15 14:04:55 2009] [error]     self.stream.write(fs % msg)
[Sun Feb 15 14:04:55 2009] [error] IOError: sys.stdout access restricted by
mod_wsgi

I have no idea what that means. any hint?

About having multithread, that's the kind of details that I can't tell, if
this is a nice/safe configuration. Anyone?


Best Regards

=========================================================

First, let's create a new Grok application, using grokproject and virtualenv
like it's explained in this tutorial:

http://grok.zope.org/documentation/how-to/using-virtualenv-for-a-clean-grok-installation

>From now on, the absolute path to the virtual environment will be called `
${sandbox} `. I will be using python2.5 in this tutorial. But you may want
to use python2.4, just be sure to use, always, the same python interpreter

Once the grok application it's installed, find out where the eggs-directory
is. If you didn't specify anything to grokproject, it should be here:

$ /home/.buildout/eggs/

Nothing to do by now, but we will need this path later.


Now, create a file called grok.wsgi in the `bin` directory of the grok
project

$ touch {sandbox}/projectname/bin/grok.wsgi

And add the following content to it:

  import os
  from paste.deploy import loadapp

  ini = '${sandbox}/projectname/etc/deploy.ini'
  application = loadapp('config:%s' % ini)


Install mod_wsgi (from the repoze.grok tutorial)

$ wget http://modwsgi.googlecode.com/files/mod_wsgi-2.1.tar.gz

$ tar xzf mod_wsgi-2.1.tar.gz
$ cd mod_wsgi-2.1
$ ./configure --with-python=${sandbox}/bin/python2.5
$ make
$ sudo make install

Once mod_wsgi is installed, the apache server needs to be told about it. On
Apache 2, this is done by adding the load declaration and any configuration
directives to the /etc/apache2/mods-available/ directory.

The load declaration for the module needs to go on a file named wsgi.load
(in /etc/apache2/mods-available/ directory), which contains only this:

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

The configuration directives reside in the file named wsgi.conf next to
wsgi.load. Create that file with this content:

  WSGIPythonHome ${sandbox}

  WSGIDaemonProcess grok user=${youruser} group=${youruser} threads=1
processes=4 maximum-requests=10000
python-path=${sandbox}/lib/python2.5/site-packages:${eggs-directory}:${sandbox}/projectname/src

  <VirtualHost *>
    ServerName localhost
    WSGIScriptAlias /grok ${sandbox}/bin/grok.wsg
    WSGIProcessGroup grok
    WSGIPassAuthorization On
    WSGIReloadMechanism Process
  </VirtualHost>

Here we use the eggs-directory in the python-path option of
WSGIDeamonProcess directive. We also need to specify the path to the project
source directory and the site-packages directory

Then you have to activate the wsgi module with:

# a2enmod wsgi

Note: a2enmod stands for "apache2 enable mod", this executable create the
symlink for you. Actually a2enmod wsgi is equivalent to:

# cd /etc/apache2/mods-enabled
# ln -s ../mods-available/wsgi.load
# ln -s ../mods-available/wsgi.conf # if it exists

Restart apache web server and you're done. Go to:

http://localhost/grok

And you will access to the gorkui.admin


======================================================================

On Sun, Feb 15, 2009 at 1:05 PM, Uli Fouquet <uli at gnufix.de> wrote:
>
> Hi Santiago,
>
> Santiago Videla wrote:
>
> > I write to know if anyone has running the latest Grok with wsgi +
> > mod_wsgi + apache.
> >
> > I saw the tutorial in grok.zope.org [1] but it use repoze.grok. I
> > guess that it's no longer needed with the latest grok release. am I
> > right?
>
> Right -- as you already discovered yourself :-)
>
> >  In fact, I have it running without repoze.grok, but I'm not sure to
> > have a "nice / safe" configuration. I used some of the hints in the
> > tutorial, in a new Grok1.0a1 installation instead of repoze.grok
>
> After your posting I tried it myself and all I needed was a very simple
> specialized runner-script and an apache config file similar to the one
> in the HOWTO. The `deploy.ini` worked out of the box. Looks like
> `grokproject` already brings most of the stuff you need to do a grok
> +apache+mod_wsgi setup :-)
>
> > If somebody already did this, I will appreciate any quick&dirty
> > tutorial. Otherwise, I will try to write it and send it to the list
> > (based on the existing tutorial, I guess).
>
> There is no such document yet AFAIK. So if you would like to write one,
> this would be great :-)
>
> Using grok with Apache/mod-wsgi might be (or become) a common usecase.
> Therefore I (as a WSGI-illiterate person) wonder, whether we should
> support generated sample apache configs and a working
> wsgi-application-creator script with `grokproject`.
>
> This would basically mean one more template in the etc/ directory and
> one more script in bin/, maybe called myapp.wsgi or similar.
>
> Alternatively this could be done by an additional recipe.
>
> Could that be useful? Or would that only complicate things further?
>
> Best regards,
>
> --
> Uli
>



--
Santiago Videla
www.revolucionesweb.com.ar
http://www.linkedin.com/in/svidela

Sigue la mata dando de que hablar siempre abajo y a la izquierda donde el
pensamiento que se hace corazón resplandece con la palabra sencilla y
humilde que l at s tod at s somos.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20090215/17b119b1/attachment.html 


More information about the Grok-dev mailing list