Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The .htaccess :

AddHandler wsgi-script .wsgi
RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.wsgi/$1 [QSA,L,PT]

The index.wsgi :

import atexit
import threading
import cherrypy

cherrypy.config.update({'environment': 'embedded'})

if cherrypy.engine.state == 0:
        cherrypy.engine.start(blocking=False)
        atexit.register(cherrypy.engine.stop)

class Root:
        def index(self):
            return "..."
            index.exposed = True

    def default(self):
            return "default"
                index.exposed = True

application = cherrypy.tree.mount(Root(), "/")
  • It is a shared host, i don't have access to apache
  • I'm not allowed to use WSGIScriptAlias

The 404 error comes from cherrypy(powered by cherrypy on the botton), so i conclude apache is calling the .wsgi file correctly, it seems that its also passing /index.wsgi/, and cherrypy does not know what to do with it.

Can anyone help me with this?

I never deployed a cherrypy app before, is this the best/only/recommended way to do it?

Thanks in advance.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If setting RewriteBase to '/' in .htaccess, likely that you need to use:

RewriteRule ^(.*)$ /index.wsgi$1 [QSA,L,PT]
share|improve this answer
    
Thank you for taking the time to answer, still Cherrypy outputs : 404 - The path '/index.wsgi' was not found. Any ideas? –  OldJim Aug 25 '10 at 16:50
    
See 'code.google.com/p/modwsgi/wiki/…;. You need to use a WSGI wrapper script to fiddle SCRIPT_NAME when you are using the rewrite rule method. Didn't catch you weren't doing this before. If that recipe has a problem now with missing slash, you may need to put it back in rewrite rule or otherwise will need to fiddle with it a bit to get it to work as example is not for .htaccess file. –  Graham Dumpleton Aug 25 '10 at 23:20
    
That was it, i had to set SCRIPT_NAME to "", that solved, tnx for the help, Jim. –  OldJim Aug 26 '10 at 1:20
    
Did you still need to drop the '/' out of the RewriteRule, or were both changes required? –  Graham Dumpleton Aug 26 '10 at 3:29
    
It worked with the .htaccess as it is in the post, the only change i made was setting environ["SCRIPT_NAME"] = "", my database connections died though (tools.cherrypy.org/wiki/Storm) apparently mod_wsgi handles threads differently, do you happen to know if there's another event where i could hook the connection?Tnx in advance. –  OldJim Aug 26 '10 at 4:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.