NSLU2-Linux
view · edit · print · history

HowTo.DeployWebAppUsingSCGI History

Hide minor edits - Show changes to markup

May 04, 2006, at 11:40 PM by Brian Zhou -- added up&running list
Changed lines 288-295 from:
  • Example lighttpd config for a Rails app
to:
  • Example lighttpd config for a Rails app

Up and Running

Let other people know that you successfully use the above procedure to run apps:

March 27, 2006, at 06:56 AM by BrianZhou --
Changed lines 287-288 from:
  • CherryPy and WSGI
to:
  • CherryPy and WSGI
  • Example lighttpd config for a Rails app
March 27, 2006, at 06:48 AM by BrianZhou --
Changed line 287 from:
to:
  • CherryPy and WSGI
March 26, 2006, at 05:56 PM by BrianZhou --
Added line 9:

At the time of this writing, py-cherrypy is 2.1.1-2.

March 26, 2006, at 07:16 AM by BrianZhou --
Deleted line 235:

server.c:843: WARNING: Unable to set file descriptor limit to 16384

March 26, 2006, at 06:23 AM by BrianZhou --
Changed lines 1-2 from:

SCGI is a simple protocol between web application and web server. Because it offers much much better performance than CGI, it is commonly used to deploy web application written in Python or Ruby.

to:

SCGI is a simple protocol between web application and web server. Because it offers much better performance than CGI, it is commonly used to deploy web application written in Python or Ruby.

Changed line 87 from:

Let's setup a static page

to:

Let's setup a static test page

Changed line 193 from:

$ /opt/sbin/lighttpd -f ~/test-scgi/lighttpd-scgi.conf @]

to:

$ /opt/sbin/lighttpd -D -f ~/test-scgi/lighttpd-scgi.conf @]

March 26, 2006, at 05:23 AM by BrianZhou --
Added line 284:

Changed lines 286-287 from:

Ruby on Rails with SCGI

to:
  • Ruby on Rails with SCGI
March 26, 2006, at 05:07 AM by BrianZhou --
Added line 120:

accesslog.filename = "/home/mylogin/tmp/lighttpd-access.log"

Changed lines 123-175 from:

accesslog.filename = "/home/mylogin/tmp/lighttpd-access.log"

to:

mimetype.assign = (

  ".pdf"          =>      "application/pdf",
  ".sig"          =>      "application/pgp-signature",
  ".spl"          =>      "application/futuresplash",
  ".class"        =>      "application/octet-stream",
  ".ps"           =>      "application/postscript",
  ".torrent"      =>      "application/x-bittorrent",
  ".dvi"          =>      "application/x-dvi",
  ".gz"           =>      "application/x-gzip",
  ".pac"          =>      "application/x-ns-proxy-autoconfig",
  ".swf"          =>      "application/x-shockwave-flash",
  ".tar.gz"       =>      "application/x-tgz",
  ".tgz"          =>      "application/x-tgz",
  ".tar"          =>      "application/x-tar",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".m3u"          =>      "audio/x-mpegurl",
  ".wma"          =>      "audio/x-ms-wma",
  ".wax"          =>      "audio/x-ms-wax",
  ".ogg"          =>      "application/ogg",
  ".wav"          =>      "audio/x-wav",
  ".gif"          =>      "image/gif",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".xbm"          =>      "image/x-xbitmap",
  ".xpm"          =>      "image/x-xpixmap",
  ".xwd"          =>      "image/x-xwindowdump",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".asc"          =>      "text/plain",
  ".c"            =>      "text/plain",
  ".cpp"          =>      "text/plain",
  ".log"          =>      "text/plain",
  ".conf"         =>      "text/plain",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
  ".mpeg"         =>      "video/mpeg",
  ".mpg"          =>      "video/mpeg",
  ".mov"          =>      "video/quicktime",
  ".qt"           =>      "video/quicktime",
  ".avi"          =>      "video/x-msvideo",
  ".asf"          =>      "video/x-ms-asf",
  ".asx"          =>      "video/x-ms-asf",
  ".wmv"          =>      "video/x-ms-wmv",
  ".bz2"          =>      "application/x-bzip",
  ".tbz"          =>      "application/x-bzip-compressed-tar",
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar"
 )
Added lines 283-285:

References:

Ruby on Rails with SCGI

March 26, 2006, at 04:34 AM by bzhou --
Added lines 191-193:

Here I'm using w3m as web browser, you can also use elinks, or any graphic browser on a different machine (adjust the URL correspondingly).

March 26, 2006, at 04:29 AM by bzhou --
Changed line 61 from:

A web app using RoR? & [http://www.zedshaw.com/projects/scgi_rails/ | SCGI Rails Runner]

to:

A web app using RoR & SCGI Rails Runner

March 26, 2006, at 04:28 AM by bzhou --
Changed line 61 from:

A simple web app using cherrypy

to:

A web app using RoR? & [http://www.zedshaw.com/projects/scgi_rails/ | SCGI Rails Runner]

March 26, 2006, at 04:27 AM by bzhou --
Changed lines 19-20 from:
  1. ipkg install py-scgi rubygems
  2. gem install rails scgi_rails --remote --include-dependencies @]
to:
  1. ipkg install rubygems
  2. gem install rails --remote --include-dependencies
  3. wget http://www.zedshaw.com/downloads/scgi_rails/scgi_rails-0.4.3.gem
  4. gem install scgi_rails-0.4.3.gem --include-dependencies@]
Added lines 61-63:

A simple web app using cherrypy

Someone please fill in the blank.

Changed line 143 from:

Or, configure cherokee

to:

Or, cherokee

March 26, 2006, at 04:17 AM by bzhou --
Changed line 20 from:
  1. gem install rails --remote --include-dependencies @]
to:
  1. gem install rails scgi_rails --remote --include-dependencies @]
Changed lines 62-63 from:

Install lighttpd

to:

lighttpd

Changed line 70 from:

Or, install cherokee

to:

Or, cherokee

Changed lines 80-81 from:

Configure the web server

to:

Configure & launch the web server

Changed lines 99-100 from:

Configure lighttpd

to:

lighttpd

Changed lines 131-132 from:

Or, configure cherokee

to:

Launch it.

Added lines 135-141:

$ /opt/sbin/lighttpd -f ~/test-scgi/lighttpd-scgi.conf @] (:tableend:)

Or, configure cherokee

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:) [@

Changed lines 170-171 from:

Test

to:

Launch it.

Changed line 175 from:

$ w3m -dump http://localhost:8081/@]

to:

$ /opt/sbin/cherokee -C ~/test-scgi/cherokee-scgi.conf @]

Added lines 178-191:

server.c:843: WARNING: Unable to set file descriptor limit to 16384 Cherokee Web Server 0.4.31b18: Listening on port 8083, TLS disabled

 IPv6? disable, using poll, 1024 fds limit, 5 threads, 204 fds in each
 standard scheduling policy@]

(:tableend:)


Test

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

$ w3m -dump http://localhost:8081/

(:cellnr bgcolor=#eeeeee:) [@

March 26, 2006, at 04:07 AM by bzhou --
Changed lines 6-8 from:

Install a web server with SCGI support

Install lighttpd

to:

Install web app framework packages

Install cherrypy

Changed line 12 from:
  1. ipkg install lighttpd @]
to:
  1. ipkg install py-cherrypy py-scgi py-paste @]
Changed line 15 from:

Or, install cherokee

to:

Or, install Ruby on rails

Changed lines 19-20 from:
  1. ipkg install cherokee@]
to:
  1. ipkg install py-scgi rubygems
  2. gem install rails --remote --include-dependencies @]
Deleted lines 22-23:

Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.

Changed lines 24-26 from:

Configure the web server

Let's setup a static page

to:

Write a web app

A simple web app using cherrypy

Changed line 31 from:

$ cat ~/public_html/static/index.html @]

to:

$ cat ~/test-scgi/test-cherrypy-scgi.py @]

Changed lines 34-41 from:

<html>

  <head>
    <title>static page</title>
  </head>
  <body>
    <h2>Testing page for the non-SCGI static content.</h2>
  </body>

</html>@]

to:

import cherrypy, datetime from cherrypy._cpwsgi import wsgiApp from paste.util.scgiserver import serve_application

class HelloWorld?:

    def index(self):
        return "%s Hello world!" % datetime.datetime.now()
    index.exposed = True

cherrypy.root = HelloWorld?()

  1. init cherrypy

cherrypy.server.start(initOnly=True, serverClass=None)

  1. run the server

serve_application(application=wsgiApp, prefix="/", port=4000) @]

Changed lines 52-54 from:

Configure lighttpd

(:table border=0 width=80%:)

to:

Launch the web app (:table border=0 width=80% bgcolor=#eeffee:)

Changed lines 56-57 from:

$ cat ~/test-scgi/lighttpd-scgi.conf @] (:cellnr bgcolor=#eeeeee:)

to:

$ python2.4 ~/test-scgi/test-cherrypy-scgi.py @] (:tableend:)


Install a web server with SCGI support

Install lighttpd

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

Changed lines 66-87 from:

server.port = 8081 server.modules = (

                                "mod_rewrite",
                                "mod_access",
                                "mod_scgi",
                                "mod_accesslog" )

server.document-root = "/home/mylogin/public_html/test-scgi" server.errorlog = "/home/mylogin/tmp/lighttpd-error.log" index-file.names = ( "index.php", "index.html",

                                "index.htm", "default.htm" )

accesslog.filename = "/home/mylogin/tmp/lighttpd-access.log" $HTTP["url"] !~ "^/static/" {

    scgi.server = (
        "/" => (
            "127.0.0.1" => (
                "host" => "127.0.0.1",
                "port" => 4000,
                "check-local" => "disable"
            )
        )
    )

}@]

to:
  1. ipkg install lighttpd @]
Changed lines 69-72 from:

Or, configure cherokee

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

to:

Or, install cherokee

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

Changed lines 73-74 from:

$ cat ~/test-scgi/cherokee-scgi.conf @] (:cellnr bgcolor=#eeeeee:)

to:
  1. ipkg install cherokee@]

(:tableend:)

Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.


Configure the web server

Let's setup a static page

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

Changed lines 85-115 from:

Port 8082 IPv6? Off Timeout 60 KeepAlive? On MaxKeepAliveRequests? 500 ServerTokens? Full PidFile? /home/mylogin/tmp/cherokee.pid Icons /opt/etc/cherokee/icons.conf MimeFile? /opt/etc/cherokee/mime.types MimeFile? /opt/etc/cherokee/mime.compression.types Include /opt/etc/cherokee/advanced.conf Include /opt/etc/cherokee/mods-enabled Documentroot /home/mylogin/public_html/test-scgi DirectoryIndex? index.html Directory /static {

    Handler file

} Directory / {

    Handler scgi {
        Server localhost:4000
        ErrorHandler? on
    }

}@] (:tableend:)


Install web app framework packages

Install cherrypy

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

to:

$ cat ~/public_html/test-scgi/static/index.html @] (:cellnr bgcolor=#eeeeee:)

Changed lines 88-95 from:
  1. ipkg install py-cherrypy py-scgi py-paste @]
to:

<html>

  <head>
    <title>static page</title>
  </head>
  <body>
    <h2>Testing page for the non-SCGI static content.</h2>
  </body>

</html>@]

Changed lines 98-100 from:

Or, install Ruby on rails

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

to:

Configure lighttpd

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

Changed lines 103-113 from:
  1. ipkg install py-scgi rubygems
  2. gem install rails --remote --include-dependencies @]

(:tableend:)


A simple web app

A simple web app using cherrypy

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

to:

$ cat ~/test-scgi/lighttpd-scgi.conf @] (:cellnr bgcolor=#eeeeee:)

Changed lines 106-107 from:

$ cat ~/test-scgi/test-cherrypy-scgi.py @] (:cellnr bgcolor=#eeeeee:)

to:

server.port = 8081 server.modules = (

                                "mod_rewrite",
                                "mod_access",
                                "mod_scgi",
                                "mod_accesslog" )

server.document-root = "/home/mylogin/public_html/test-scgi" server.errorlog = "/home/mylogin/tmp/lighttpd-error.log" index-file.names = ( "index.php", "index.html",

                                "index.htm", "default.htm" )

accesslog.filename = "/home/mylogin/tmp/lighttpd-access.log" $HTTP["url"] !~ "^/static/" {

    scgi.server = (
        "/" => (
            "127.0.0.1" => (
                "host" => "127.0.0.1",
                "port" => 4000,
                "check-local" => "disable"
            )
        )
    )

}@] (:tableend:)

Or, configure cherokee

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

Changed lines 135-153 from:

import cherrypy, datetime from cherrypy._cpwsgi import wsgiApp from paste.util.scgiserver import serve_application

class HelloWorld?:

    def index(self):
        return "%s Hello world!" % datetime.datetime.now()
    index.exposed = True

cherrypy.root = HelloWorld?()

  1. init cherrypy

cherrypy.server.start(initOnly=True, serverClass=None)

  1. run the server

serve_application(application=wsgiApp, prefix="/", port=4000) @] (:cellnr bgcolor=#ffff:)

(:cellnr bgcolor=#eeffee:)

to:

$ cat ~/test-scgi/cherokee-scgi.conf @] (:cellnr bgcolor=#eeeeee:)

Changed lines 138-160 from:

$ python2.4 ~/test-scgi/test-cherrypy-scgi.py @]

to:

Port 8082 IPv6? Off Timeout 60 KeepAlive? On MaxKeepAliveRequests? 500 ServerTokens? Full PidFile? /home/mylogin/tmp/cherokee.pid Icons /opt/etc/cherokee/icons.conf MimeFile? /opt/etc/cherokee/mime.types MimeFile? /opt/etc/cherokee/mime.compression.types Include /opt/etc/cherokee/advanced.conf Include /opt/etc/cherokee/mods-enabled Documentroot /home/mylogin/public_html/test-scgi DirectoryIndex? index.html Directory /static {

    Handler file

} Directory / {

    Handler scgi {
        Server localhost:4000
        ErrorHandler? on
    }

}@]

March 26, 2006, at 03:57 AM by bzhou --
Changed lines 27-28 from:

Configure lighttpd

to:

Let's setup a static page

Changed line 31 from:

$ cat ~/test-scgi/lighttpd-scgi.conf @]

to:

$ cat ~/public_html/static/index.html @]

Added lines 34-51:

<html>

  <head>
    <title>static page</title>
  </head>
  <body>
    <h2>Testing page for the non-SCGI static content.</h2>
  </body>

</html>@] (:tableend:)

Configure lighttpd

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

$ cat ~/test-scgi/lighttpd-scgi.conf 

(:cellnr bgcolor=#eeeeee:) [@

Added line 76:
Deleted line 197:
March 26, 2006, at 03:53 AM by bzhou --
Added line 137:
Changed lines 176-178 from:

$ w3m -dump http://localhost:8083/static/index.html

to:

$ w3m -dump http://localhost:8083/static/index.html@] (:cellnr bgcolor=#eeeeee:) [@

March 26, 2006, at 03:51 AM by bzhou --
Added line 35:

server.port = 8081

Changed lines 56-58 from:

} server.port = 8081 @]

to:

}@]

Changed lines 88-89 from:

} @]

to:

}@]

Added line 136:

(:cellnr bgcolor=#ffff:)

Changed lines 160-161 from:

Testing page for the non-SCGI static content. @]

to:

Testing page for the non-SCGI static content.@]

Added lines 171-174:

(:cellnr bgcolor=#ffff:)

(:cellnr bgcolor=#eeffee:) [@

Changed lines 176-178 from:

Testing page for the non-SCGI static content.

to:

Testing page for the non-SCGI static content.@]

March 26, 2006, at 03:49 AM by bzhou --
Changed lines 153-154 from:

Build time: 0.061s, Page size: 0.03KB @]

to:

Build time: 0.061s, Page size: 0.03KB@] (:cellnr bgcolor=#ffff:)

Deleted line 161:
Added lines 163-164:

(:cellnr bgcolor=#ffff:)

Changed lines 172-173 from:

Build time: 0.074s, Page size: 0.03KB @]

to:

Build time: 0.074s, Page size: 0.03KB@] $ w3m -dump http://localhost:8083/static/index.html Testing page for the non-SCGI static content.

March 26, 2006, at 03:45 AM by bzhou --
Changed lines 91-92 from:
to:

(:tableend:)

Changed lines 168-170 from:

2006-03-25 19:43:37.34 Hello world!

Build time: 0.061s, Page size: 0.03KB

to:

2006-03-25 19:51:16.82 Hello world!

Build time: 0.074s, Page size: 0.03KB

March 26, 2006, at 03:43 AM by bzhou --
Added line 137:

(:cellnr bgcolor=#eeffee:)

Changed line 156 from:

$ w3m -dump http://localhost:8081/static/

to:

$ w3m -dump http://localhost:8081/static/@]

March 26, 2006, at 03:42 AM by bzhou --
Changed lines 61-67 from:

Install web app framework packages

Install cherrypy

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

to:

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

Changed lines 64-69 from:
  1. ipkg install py-cherrypy py-scgi py-paste @]

(:tableend:)

Or, install Ruby on rails

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

to:

$ cat ~/test-scgi/cherokee-scgi.conf @] (:cellnr bgcolor=#eeeeee:)

Changed lines 67-70 from:
  1. ipkg install py-scgi rubygems
  2. gem install rails --remote --include-dependencies @]

(:tableend:)

to:

Port 8082 IPv6? Off Timeout 60 KeepAlive? On MaxKeepAliveRequests? 500 ServerTokens? Full PidFile? /home/mylogin/tmp/cherokee.pid Icons /opt/etc/cherokee/icons.conf MimeFile? /opt/etc/cherokee/mime.types MimeFile? /opt/etc/cherokee/mime.compression.types Include /opt/etc/cherokee/advanced.conf Include /opt/etc/cherokee/mods-enabled Documentroot /home/mylogin/public_html/test-scgi DirectoryIndex? index.html Directory /static {

    Handler file

} Directory / {

    Handler scgi {
        Server localhost:4000
        ErrorHandler? on
    }

} @]

Changed lines 93-97 from:

A simple web app

A simple web app using cherrypy

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

to:

Install web app framework packages

Install cherrypy

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

Changed lines 99-100 from:

$ cat ~/test-scgi/test-cherrypy-scgi.py @] (:cellnr bgcolor=#eeeeee:)

to:
  1. ipkg install py-cherrypy py-scgi py-paste @]

(:tableend:)

Or, install Ruby on rails

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

Added lines 106-120:
  1. ipkg install py-scgi rubygems
  2. gem install rails --remote --include-dependencies @]

(:tableend:)


A simple web app

A simple web app using cherrypy

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

$ cat ~/test-scgi/test-cherrypy-scgi.py 

(:cellnr bgcolor=#eeeeee:) [@

Added lines 137-138:
$ python2.4 ~/test-scgi/test-cherrypy-scgi.py 
Added lines 143-170:

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

$ w3m -dump http://localhost:8081/

(:cellnr bgcolor=#eeeeee:)

2006-03-25 19:43:37.34 Hello world!

Build time: 0.061s, Page size: 0.03KB

(:cellnr bgcolor=#eeffee:)

$ w3m -dump http://localhost:8081/static/
(:cellnr bgcolor=#eeeeee:)
[@
Testing page for the non-SCGI static content.

(:cellnr bgcolor=#eeffee:)

$ w3m -dump http://localhost:8082/

(:cellnr bgcolor=#eeeeee:)

2006-03-25 19:43:37.34 Hello world!

Build time: 0.061s, Page size: 0.03KB

(:tableend:)

March 26, 2006, at 03:25 AM by bzhou --
Changed line 77 from:
  1. gem install rails @]
to:
  1. gem install rails --remote --include-dependencies @]
March 26, 2006, at 03:21 AM by bzhou --
Changed line 45 from:

$HTTP["url"] !~ "^/static/" {

to:

$HTTP["url"] !~ "^/static/" {

Changed line 55 from:

}

to:

}

Changed line 69 from:
  1. ipkg install py-cherrypy py-mx-base py-scgi @]
to:
  1. ipkg install py-cherrypy py-scgi py-paste @]
Changed lines 90-91 from:

import cherrypy import mx.DateTime?

to:

import cherrypy, datetime

Changed line 96 from:
        return "%s Hello world!" % mx.DateTime?.now()
to:
        return "%s Hello world!" % datetime.datetime.now()
March 26, 2006, at 03:07 AM by bzhou --
Changed line 38 from:
                                "mod_scgi",
to:
                                "mod_scgi",
Changed lines 40-41 from:

server.document-root = "/home/yourlogin/public_html/test-scgi" server.errorlog = "/home/yourlogin/tmp/lighttpd-error.log"

to:

server.document-root = "/home/mylogin/public_html/test-scgi" server.errorlog = "/home/mylogin/tmp/lighttpd-error.log"

Changed line 44 from:

accesslog.filename = "/home/yourlogin/tmp/lighttpd-access.log"

to:

accesslog.filename = "/home/mylogin/tmp/lighttpd-access.log"

March 26, 2006, at 03:02 AM by bzhou --
Changed line 38 from:
                                "mod_scgi",
to:
                                "mod_scgi",
Changed lines 40-41 from:

server.document-root = "/home/yourlogin/public_html/test-scgi" server.errorlog = "/home/yourlogin/tmp/lighttpd-error.log"

to:

server.document-root = "/home/yourlogin/public_html/test-scgi" server.errorlog = "/home/yourlogin/tmp/lighttpd-error.log"

Changed lines 44-45 from:

accesslog.filename = "/home/yourlogin/tmp/lighttpd-access.log" '''$HTTP["url"] !~ "^/static/" {

to:

accesslog.filename = "/home/yourlogin/tmp/lighttpd-access.log" $HTTP["url"] !~ "^/static/" {

Changed line 55 from:

}'''

to:

}

March 26, 2006, at 02:57 AM by bzhou --
Changed lines 29-36 from:

Or, configure cherokee


Install web app framework packages

Install cherrypy

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

to:

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

Changed lines 32-37 from:
  1. ipkg install py-cherrypy py-mx-base py-scgi @]

(:tableend:)

Or, install Ruby on rails

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

to:

$ cat ~/test-scgi/lighttpd-scgi.conf @] (:cellnr bgcolor=#eeeeee:)

Changed lines 35-36 from:
  1. ipkg install py-scgi rubygems
  2. gem install rails @]
to:

server.modules = (

                                "mod_rewrite",
                                "mod_access",
                                "mod_scgi",
                                "mod_accesslog" )

server.document-root = "/home/yourlogin/public_html/test-scgi" server.errorlog = "/home/yourlogin/tmp/lighttpd-error.log" index-file.names = ( "index.php", "index.html",

                                "index.htm", "default.htm" )

accesslog.filename = "/home/yourlogin/tmp/lighttpd-access.log" '''$HTTP["url"] !~ "^/static/" {

    scgi.server = (
        "/" => (
            "127.0.0.1" => (
                "host" => "127.0.0.1",
                "port" => 4000,
                "check-local" => "disable"
            )
        )
    )

}''' server.port = 8081 @]

Added lines 60-61:

Or, configure cherokee

Changed lines 63-67 from:

A simple web app

A simple web app using cherrypy

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

to:

Install web app framework packages

Install cherrypy

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

Changed lines 69-70 from:

$ cat ~/test-scgi/test-cherrypy-scgi.py @] (:cellnr bgcolor=#eeeeee:)

to:
  1. ipkg install py-cherrypy py-mx-base py-scgi @]

(:tableend:)

Or, install Ruby on rails

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

Added lines 76-89:
  1. ipkg install py-scgi rubygems
  2. gem install rails @]

(:tableend:)


A simple web app

A simple web app using cherrypy

(:table border=0 width=80%:) (:cellnr bgcolor=#eeffee:)

$ cat ~/test-scgi/test-cherrypy-scgi.py 

(:cellnr bgcolor=#eeeeee:) [@

March 26, 2006, at 02:46 AM by bzhou --
Changed line 54 from:

(:cellnr (bgcolor=#eeffee):)

to:

(:cellnr bgcolor=#eeffee:)

Changed line 57 from:

(:cellnr (bgcolor=#ee00ee):)

to:

(:cellnr bgcolor=#eeeeee:)

March 26, 2006, at 01:26 AM by bzhou --
Changed line 54 from:

(:cell (bgcolor=#eeffee):)

to:

(:cellnr (bgcolor=#eeffee):)

Changed line 57 from:

(:cell (bgcolor=#ee00ee):)

to:

(:cellnr (bgcolor=#ee00ee):)

March 26, 2006, at 01:25 AM by bzhou --
Changed line 53 from:

(:table border=0 width=80% :)

to:

(:table border=0 width=80%:)

Changed line 57 from:

(:cellnr (bgcolor=#ee00ee):)

to:

(:cell (bgcolor=#ee00ee):)

March 26, 2006, at 01:24 AM by bzhou --
Changed lines 53-54 from:

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

to:

(:table border=0 width=80% :) (:cell (bgcolor=#eeffee):)

Changed line 57 from:

(:cellnr (bgcolor=#eeeeee):)

to:

(:cellnr (bgcolor=#ee00ee):)

March 26, 2006, at 01:22 AM by bzhou --
Changed line 57 from:

(:cellnr (bgcolor=#eeffef):)

to:

(:cellnr (bgcolor=#eeeeee):)

March 26, 2006, at 01:21 AM by bzhou --
Changed line 56 from:

$ cat ~/test-scgi/test-cherrypy-scgi.py

to:

$ cat ~/test-scgi/test-cherrypy-scgi.py @]

Added line 58:

[@

March 26, 2006, at 01:21 AM by bzhou --
Added line 57:

(:cellnr (bgcolor=#eeffef):)

March 26, 2006, at 01:18 AM by bzhou --
Changed line 38 from:
  1. ipkg install py-cherrypy @]
to:
  1. ipkg install py-cherrypy py-mx-base py-scgi @]
Changed line 45 from:
  1. ipkg install rubygems
to:
  1. ipkg install py-scgi rubygems
March 26, 2006, at 01:16 AM by bzhou --
Changed lines 73-74 from:

serve_application(application=wsgiApp, prefix="/", port=4000) @]

to:

serve_application(application=wsgiApp, prefix="/", port=4000) @]

March 26, 2006, at 01:16 AM by bzhou --
Changed lines 53-76 from:
to:

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

$ cat ~/test-scgi/test-cherrypy-scgi.py 
import cherrypy
import mx.DateTime
from cherrypy._cpwsgi import wsgiApp
from paste.util.scgiserver import serve_application

class HelloWorld:
    def index(self):
        return "%s Hello world!" % mx.DateTime.now()
    index.exposed = True

cherrypy.root = HelloWorld()

# init cherrypy
cherrypy.server.start(initOnly=True, serverClass=None)

# run the server
serve_application(application=wsgiApp, prefix="/", port=4000)

(:tableend:)

March 26, 2006, at 01:14 AM by bzhou --
Changed line 12 from:

ipkg install lighttpd @]

to:
  1. ipkg install lighttpd @]
Changed line 19 from:

ipkg install cherokee@]

to:
  1. ipkg install cherokee@]
Changed line 38 from:

ipkg install py-cherrypy @]

to:
  1. ipkg install py-cherrypy @]
Changed lines 45-46 from:

ipkg install rubygems gem install rails @]

to:
  1. ipkg install rubygems
  2. gem install rails @]
March 26, 2006, at 01:07 AM by bzhou --
Changed lines 21-22 from:

Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.

to:

Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.

Changed lines 35-40 from:
to:

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

ipkg install py-cherrypy 

(:tableend:)

Changed lines 42-48 from:
to:

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

ipkg install rubygems
gem install rails 

(:tableend:)

March 26, 2006, at 01:02 AM by bzhou --
Changed lines 21-22 from:
to:

Please note cherokee 0.4.31b18 fixed a couple of SCGI/FastCGI problems. Version earlier than this probably does not work.

March 26, 2006, at 12:56 AM by bzhou --
Changed lines 9-14 from:
to:

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

ipkg install lighttpd 

(:tableend:)

Changed lines 16-21 from:
to:

(:table border=0 width=80% bgcolor=#eeffee:) (:cell:)

ipkg install cherokee

(:tableend:)

March 26, 2006, at 12:39 AM by bzhou -- initial version
Added lines 1-32:

SCGI is a simple protocol between web application and web server. Because it offers much much better performance than CGI, it is commonly used to deploy web application written in Python or Ruby.

The example below is on unslung firmware and using optware packages.


Install a web server with SCGI support

Install lighttpd

Or, install cherokee


Configure the web server

Configure lighttpd

Or, configure cherokee


Install web app framework packages

Install cherrypy

Or, install Ruby on rails


A simple web app

A simple web app using cherrypy


Test

view · edit · print · history · Last edited by Brian Zhou.
Based on work by BrianZhou and bzhou.
Originally by bzhou.
Page last modified on May 04, 2006, at 11:40 PM