WebFaction
Community site: login faq

As my forum title says above, I am not able to get web.py running under lighttpd fastcgi. Static files are returning fine, but request for the python code just downloads the file source code.

Here's my web.py python code:

#!/usr/local/bin/python2.7
from flup.server.fcgi import WSGIServer
import web

urls = (
    '/.*', 'home',
    '/me', 'me'
)

class home:
    def GET(self):
        return 'this is the home page'

class me:
    def GET(self):
        return 'this is my page'

app = web.application(urls, globals())

web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)

if __name__ == "__main__":
    app.run()

Here's my fastcgi config file:

server.document-root = "/home/neorou73/webapps/fastcgi1/pages"
server.port          = 32053
server.modules       = ( "mod_accesslog", "mod_rewrite", "mod_fastcgi" )
accesslog.filename   = "/home/neorou73/webapps/fastcgi1/access.log"
server.errorlog      = "/home/neorou73/webapps/fastcgi1/error.log"
fastcgi.debug        = 1
fastcgi.map-extensions = (".py" => ".py")
fastcgi.server       = ( "/code.py" =>
                       ( "/" =>
                           ( "socket" => "/home/neorou73/webapps/fastcgi1/pages/app/fastcgi.python.sock",
                             "bin-path" => "/home/neorou73/webapps/fastcgi1/pages/app/code.py",
                             "max-procs" => 1,
                             "bin-environment" => (
                                 "REAL_SCRIPT_NAME" => ""
                                 ),
                             "check-local" => "disable"
                           )
                        )
                   )

mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png"
)

Can somebody help me figure out what is wrong? Please do not advise me to use a different platform because it is easier. I got web.py working at home, have a bunch of code I would like to use for production, but I can not seem to get it to work properly on this host.

Thanks in advance...

asked 07 Aug '12, 09:20

neorou73
3123
accept rate: 0%


Since we do not use lighttp normally I can't be sure without testing, but I think it is these lines,

fastcgi.server       = ( "/code.py" =>
                         "bin-path" => "/home/neorou73/webapps/fastcgi1/pages/app/code.py",

Try this,

fastcgi.server       = ( ".py" =>
                         "bin-path" => "code.py",

Their documentation shows a basic example and includes a forum thread which explains it.

permanent link

answered 07 Aug '12, 17:40

johns
5.4k312
accept rate: 23%

Thanks, johns. the python code is being accessed properly, but the server simply returns the file as a download, and not pass it through the fastcgi processor.

(09 Aug '12, 09:53) neorou73

Hi,

Have you tried doing the change my colleague suggested, and restarting lighthttpd after that? I suggest that you also try adding this line:

   "fix-root-scriptname" => "enable",

(after the "check-local" => "disable" line) Make sure you restart lighthttpd after you make any such change.

(10 Aug '12, 02:13) todork
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×11
×3

question asked: 07 Aug '12, 09:20

question was seen: 8,179 times

last updated: 10 Aug '12, 02:13

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM