Hi matthew,

I've also battled with mod_fcgi to make pylons application work. In
the end, I've won :)

On 8/13/06, Matthew Burgess <[EMAIL PROTECTED]> wrote:

> Having just battled trying to get my FCGI-based deployment working, I'm
> not happy with the solution I've found!  Basically, what was happening
> was that the dispatch.fcgi script (taken from
> http://www.pylonshq.com/project/pylonshq/wiki/FastCGI) couldn't import
> the paste.deploy module because it was installed in my home directory
> along with the rest of the Pylons modules.  mod_fastcgi kindly ignores
> any SetEnv directives in my .htaccess file, which was enough to get
> dispatch.cgi to work.

In my case, my webhost runs mod_suexec, so that fcgi scripts are
running under my id. In that case, SetEnv directives in .htaccess
files are ignored when the fcgi script is launched.

So, I've modified dispatch.fcgi to include the path to my own python
lib. dispatch.fcgi looks like this :

#!/home/login/bin/python -S

import os, sys
paths = ["/home/login/lib/python2.4/site-packages/"]
os.environ["PYTHONPATH"] = os.pathsep.join(paths)
sys.path[0:0] = paths
import site


# Load the WSGI application from the config file
from paste.deploy import loadapp
wsgi_app = loadapp('config:/home/login/production.ini')

# Deploy it using FastCGI
if __name__ == '__main__':
    from flup.server.fcgi import WSGIServer
    WSGIServer(wsgi_app).run()


The important part is the beginning of the file : the python
interpreter is started with the -S option, to disable  the  import  of
 the  module  site. Then I add my own python lib to the sys.path. And
then I import the site.
I've also modified dispatch.cgi.

I also had to modify my .htaccess, because I had recursion limit
errors with mod_rewrite. The rules I've added are :

RewriteRule ^$ /dispatch.fcgi/ [L]
RewriteCond %{REQUEST_URI} !^/dispatch.fcgi/.*
RewriteRule ^(.*)$ /dispatch.fcgi/$1 [QSA,L]

I had to add the rewrite condition RewriteCond to avoid infinite
recursion : it seems that whenever you terminate the rule with L,
httpd will reapply all the rules to the new url. That is only the case
if rules are set in .htaccess.

Now my pylons application works in my shared web hosting.

Mathias

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---

Reply via email to