Hey,<br><br>Well, here is what I did. I&#39;m not a very good tutorials writer (and my English it&#39;s a little bit poor...), so maybe Uli or somebody else could re-write this to publish it on <a href="http://grok.zope.org">grok.zope.org</a>. Or we can just wait, until grokproject take care of whole story. :)<br>
<br>All seems to work fine, but I&#39;m getting an error in the apache logs:<br><br>[Sun Feb 15 14:04:55 2009] [error] Traceback (most recent call last):<br>[Sun Feb 15 14:04:55 2009] [error]&nbsp;&nbsp; File &quot;/usr/lib/python2.5/logging/__init__.py&quot;, line 750, in emit<br>
[Sun Feb 15 14:04:55 2009] [error]&nbsp;&nbsp;&nbsp;&nbsp; self.stream.write(fs % msg)<br>[Sun Feb 15 14:04:55 2009] [error] IOError: sys.stdout access restricted by mod_wsgi<br><br>I have no idea what that means. any hint?<br><br>About having multithread, that&#39;s the kind of details that I can&#39;t tell, if this is a nice/safe configuration. Anyone?<br>
<br><br>Best Regards<br><br>=========================================================<br><br>First, let&#39;s create a new Grok application, using grokproject and virtualenv like it&#39;s explained in this tutorial:<br><br>
<a href="http://grok.zope.org/documentation/how-to/using-virtualenv-for-a-clean-grok-installation">http://grok.zope.org/documentation/how-to/using-virtualenv-for-a-clean-grok-installation</a><br><br>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<br>
<br>Once the grok application it&#39;s installed, find out where the eggs-directory is. If you didn&#39;t specify anything to grokproject, it should be here:<br><br>$ /home/.buildout/eggs/<br><br>Nothing to do by now, but we will need this path later.<br>
<br><br>Now, create a file called grok.wsgi in the `bin` directory of the grok project<br><br>$ touch {sandbox}/projectname/bin/grok.wsgi<br><br>And add the following content to it:<br><br>&nbsp; import os<br>&nbsp; from paste.deploy import loadapp<br>
<br>&nbsp; ini = &#39;${sandbox}/projectname/etc/deploy.ini&#39;<br>&nbsp; application = loadapp(&#39;config:%s&#39; % ini)<br><br><br>Install mod_wsgi (from the repoze.grok tutorial)<br><br>$ wget <a href="http://modwsgi.googlecode.com/files/mod_wsgi-2.1.tar.gz">http://modwsgi.googlecode.com/files/mod_wsgi-2.1.tar.gz</a><br>
<br>$ tar xzf mod_wsgi-2.1.tar.gz<br>$ cd mod_wsgi-2.1<br>$ ./configure --with-python=${sandbox}/bin/python2.5<br>$ make<br>$ sudo make install<br><br>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.<br>
<br>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:<br><br>LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so<br><br>
The configuration directives reside in the file named wsgi.conf next to wsgi.load. Create that file with this content:<br><br>&nbsp; WSGIPythonHome ${sandbox}<br><br>&nbsp; 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<br>
<br>&nbsp; &lt;VirtualHost *&gt;<br>&nbsp;&nbsp;&nbsp; ServerName localhost<br>&nbsp;&nbsp;&nbsp; WSGIScriptAlias /grok ${sandbox}/bin/grok.wsg<br>&nbsp;&nbsp;&nbsp; WSGIProcessGroup grok<br>&nbsp;&nbsp;&nbsp; WSGIPassAuthorization On<br>&nbsp;&nbsp;&nbsp; WSGIReloadMechanism Process<br>&nbsp; &lt;/VirtualHost&gt;<br>
<br>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<br><br>Then you have to activate the wsgi module with:<br>
<br># a2enmod wsgi<br><br>Note: a2enmod stands for &quot;apache2 enable mod&quot;, this executable create the symlink for you. Actually a2enmod wsgi is equivalent to:<br><br># cd /etc/apache2/mods-enabled<br># ln -s ../mods-available/wsgi.load<br>
# ln -s ../mods-available/wsgi.conf # if it exists<br><br>Restart apache web server and you&#39;re done. Go to:<br><br><a href="http://localhost/grok">http://localhost/grok</a><br><br>And you will access to the gorkui.admin<br>
<br><br>======================================================================<br><br>On Sun, Feb 15, 2009 at 1:05 PM, Uli Fouquet &lt;<a href="mailto:uli@gnufix.de">uli@gnufix.de</a>&gt; wrote:<br>&gt;<br>&gt; Hi Santiago,<br>
&gt;<br>&gt; Santiago Videla wrote:<br>&gt;<br>&gt; &gt; I write to know if anyone has running the latest Grok with wsgi +<br>&gt; &gt; mod_wsgi + apache.<br>&gt; &gt;<br>&gt; &gt; I saw the tutorial in <a href="http://grok.zope.org">grok.zope.org</a> [1] but it use repoze.grok. I<br>
&gt; &gt; guess that it&#39;s no longer needed with the latest grok release. am I<br>&gt; &gt; right?<br>&gt;<br>&gt; Right -- as you already discovered yourself :-)<br>&gt;<br>&gt; &gt; &nbsp;In fact, I have it running without repoze.grok, but I&#39;m not sure to<br>
&gt; &gt; have a &quot;nice / safe&quot; configuration. I used some of the hints in the<br>&gt; &gt; tutorial, in a new Grok1.0a1 installation instead of repoze.grok<br>&gt;<br>&gt; After your posting I tried it myself and all I needed was a very simple<br>
&gt; specialized runner-script and an apache config file similar to the one<br>&gt; in the HOWTO. The `deploy.ini` worked out of the box. Looks like<br>&gt; `grokproject` already brings most of the stuff you need to do a grok<br>
&gt; +apache+mod_wsgi setup :-)<br>&gt;<br>&gt; &gt; If somebody already did this, I will appreciate any quick&amp;dirty<br>&gt; &gt; tutorial. Otherwise, I will try to write it and send it to the list<br>&gt; &gt; (based on the existing tutorial, I guess).<br>
&gt;<br>&gt; There is no such document yet AFAIK. So if you would like to write one,<br>&gt; this would be great :-)<br>&gt;<br>&gt; Using grok with Apache/mod-wsgi might be (or become) a common usecase.<br>&gt; Therefore I (as a WSGI-illiterate person) wonder, whether we should<br>
&gt; support generated sample apache configs and a working<br>&gt; wsgi-application-creator script with `grokproject`.<br>&gt;<br>&gt; This would basically mean one more template in the etc/ directory and<br>&gt; one more script in bin/, maybe called myapp.wsgi or similar.<br>
&gt;<br>&gt; Alternatively this could be done by an additional recipe.<br>&gt;<br>&gt; Could that be useful? Or would that only complicate things further?<br>&gt;<br>&gt; Best regards,<br>&gt;<br>&gt; --<br>&gt; Uli<br>&gt;<br>
<br><br><br>--<br>Santiago Videla<br><a href="http://www.revolucionesweb.com.ar">www.revolucionesweb.com.ar</a><br><a href="http://www.linkedin.com/in/svidela">http://www.linkedin.com/in/svidela</a><br><br>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@s tod@s somos.<br>