#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

"""
This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro <[email protected]>
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)

This is a handler for lighttpd+fastcgi
This file has to be in the PYTHONPATH
Put something like this in the lighttpd.conf file:

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'
                        )
                    )
                 )
"""

LOGGING = False
SOFTCRON = False

import sys
import os

path = os.path.dirname(os.path.abspath(__file__))
os.chdir(path)
sys.path = [path] + [p for p in sys.path if not p == path]

import gluon.main
import gluon.contrib.gateways.fcgi as fcgi

if LOGGING:
    application = gluon.main.appfactory(wsgiapp=gluon.main.wsgibase,
                                        logfilename='httpserver.log',
                                        profilerfilename=None)
else:
    application = gluon.main.wsgibase

if SOFTCRON:
    from gluon.settings import global_settings
    global_settings.web2py_crontype = 'soft'

fcgi.WSGIServer(application).run()


Agreed, fcgihandler is not from contrib.  I have posted source from my 
fcgihandler.  As previously stated, I modified the bind address on the 
final line.

Notice that fcgi is imported from gluon.contrib.gateways and it is the file 
that chokes when the env is python3

This should function as I have 2 running instances of this right now.  And 
have in the past used this on many other projects.

On Tuesday, November 20, 2018 at 10:38:44 PM UTC-6, 黄祥 wrote:
>
> trying to investigate, but seems the configuration isn't work, step i took
> docker pull ubuntu
> docker run -it ubuntu /bin/bash
>
> apt update
> apt install -y lighttpd python python-fcgi unzip wget 
> mkdir /srv
> cd /srv
> wget -c http://web2py.com/examples/static/web2py_src.zip
> unzip -o web2py_src.zip
> #cp web2py/gluon/contrib/gateways/fcgi.py web2py/
> cp web2py/handlers/fcgihandler.py web2py/
> cp /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.ori
>
> #chmod 777 /srv/web2py/fcgi.py
> chmod 777 /srv/web2py/fcgihandler.py
>
> echo '' > /var/log/lighttpd/error.log
> cat << EOF > /etc/lighttpd/lighttpd.conf
> server.modules = (
>         "mod_access",
>         "mod_alias",
>         "mod_compress",
>         "mod_redirect",
> )
> server.modules += ("mod_fastcgi")
> server.document-root        = "/srv/web2py/"
> server.errorlog             = "/var/log/lighttpd/error.log"
> server.port                 = 80
> fastcgi.debug = 1
> \$HTTP["url"] !~ "^/static" {
> fastcgi.server = ( "" => ((
>         "bin-path" => "/srv/web2py/fcgihandler.py",
>         "check-local" => "disable",
>         "socket" => "/tmp/web2py.sock",
>         "max-procs" => 4
> )))
> }
> EOF
> service lighttpd restart
> cat /var/log/lighttpd/error.log
>
> fcgi handler is taken from web2py/handlers/ not from 
> web2py/gluon/contrib/gateways, server is run just a couple of second then 
> die. investigate using python2 first, then try python3 but python2 is can't 
> run
>
> best regards,
> stifan
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to