Debian 7 with Lighttpd + web2py setup

179 views
Skip to first unread message

Jon M.

unread,
Feb 2, 2015, 6:20:24 PM2/2/15
to web...@googlegroups.com
Peaceful greetings Google Group Members and Mr. Di Pierro.

First of all, thanks to all of you, web2py dev team, group members,for giving us the power of deploying with such a complete python web framework. I can imagine the heavy load of work behind from its beginning, to present day.

The thing is, I'm struggling with the setup of lighty with web2py.

  - I want to work only with Lighttpd as if I were working with Rocket, therefore, I want to disable Rocket at web2py startup.
  - The /etc/lighttpd/lighttpd.conf setup, as in many blogs, as in official web2py manual at the lighttpd recipe, does not work for me.
  - When starting web2py at the desired port 80 or 8000, Rocket claims that port, so, it doesn't start.
 
Some doubts with suggestion of being clear:

 > Nowhere says if code needs to be replaced, added or overwritten. Kinda mixed code from many places regarding lighty with web2py.

 > Some URLs are not clear, from a glimpse someone can see URL for Windows paths, others for UNIX.

 > Some authors use /var/www/web2py, while others use /home/www-data/web2py. Which one is the one and why?

 > Is that configuration even possible? I've been working-learning web2py for almost half-year and I just can't get there.

Here's what I have in /etc/lighttpd/lighttpd.conf:

server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_rewrite",
        "mod_fastcgi",
        "mod_accesslog",
        "mod_status",
)
 
server.port                 = 8000
server.bind                 = "127.0.0.1"
server.event-handler        = "poll"  
server.dir-listing          = "disable"
server.upload-dirs          = ("/var/cache/lighttpd/uploads")
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data" 
server.error-handler-404    = "/test.fcgi"
server.document-root        = "/home/www-data/web2py"
server.errorlog             = "/tmp/error.log"

fastcgi.server              = (".fcgi" =>
                                        ("fcgihandler" =>
                                                        ("min-procs" => 1,
                                                         "socket"    => "/tmp/fcgi.sock"
                                                        )
                                        )
                              )

index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

#w2p

$HTTP["host"] =~ "(^|\.)example\.com$" {
  server.document-root = "/home/www-data/web2py"
    url.rewrite-once = (
      "^(/.+?/static/.+)$" => "/applications$1",
      "^(/static/.+)$" => "/applications/app$1",
      "^/$" => "/fcgihandler.fcgi/app/default/index",
      "(^/app.*)$" => "/fcgihandler.fcgi$1",
      "(^/admin.*)$" => "/fcgihandler.fcgi$1",
      "(^/examples.*)$" => "/fcgihandler.fcgi$1",
      "(^/welcome.*)$" => "/fcgihandler.fcgi$1",
      "(^|/.*)$" => "/fcgihandler.fcgi/app/default/$1",
    )
}


The fcgihandler.fcgi is the default from the handlers folder under web2py.

 -- I copied the handler under /home/www-data/web2py/handlers/fcgihandler.py to /home/www-data/web2py/, and changed the *.py extension to *.fcgi.
 -- I changed the name of handler as suggested here: http://web2py.googlegroups.com/attach/e96c0ab84d8e474e/tutorial.htm?view=1&part=2
 -- I've already stopped whatever wanted to make use of the port 80. Apache2 mostly.
 -- I run the "sudo -u www-data python fcgihandler.fcgi", as stated in the link above. Prior to run web2py, and prior to restarting lighttpd with the custom configuration. No success.

I appreciate your time taken to read this, and your help.

Have a nice day/night everyone! :D

P.D.: Spanish spoken too. Just in case. [:

Massimo Di Pierro

unread,
Feb 5, 2015, 4:37:55 PM2/5/15
to web...@googlegroups.com
Thanks Jon.

I have not used this in long time (4 years?) and there has not been much talk about lighttpd since nginx. Anyway I think you do this:

1) copy web2py/handlers/
fcgihandler.py to web2py/fcgihandler.py but you should not rename it.
2) you start it with sudo -u www-data python fcgihandler.py and it will open and listen from the /tmp/fcgi.sock socket.
3) The lighttpd should be something like:

server.port = 8000                                                                            
server.bind = '127.0.0.1'                                                                     
server.event-handler = 'freebsd-kqueue'                                                       
server.modules = ('mod_rewrite', 'mod_fastcgi')                                               
server.error-handler-404 = '/test.fcgi'                                                       
server.document-root = '/somewhere/web2py'                                                    
server.errorlog      = '/tmp/error.log'                                                       
fastcgi.server = ('.fcgi' =>                                                                  
                    ('localhost' =>                                                           
                        ('min-procs' => 1,                                                    
                         'socket'    => '/tmp/fcgi.sock'                                      
                        )                                                                     
                    )                                                                         
                 )   

Lines like this:
"(^|/.*)$" => "/fcgihandler.fcgi/app/default/$1",
should not be in the lighttpd.conf
Reply all
Reply to author
Forward
0 new messages