Pylons + lighttpd + SCGI

February 23, 2007

Pylons is a raid web development framework, based on Rails for the Python language. Our website and applications are rendered in this framework.

Here is a simplistic example of how to deploy your Pylons app using lighttpd 1.4 and SCGI. You need to have flup and scgi installed before proceding, use easy_install to do this.

The lighttpd.conf file:

# lighttpd configuration file
#

# default document-root
server.document-root = “/opt/Entic/entic”

# selecting modules
server.modules = ( “mod_scgi”, “mod_accesslog” )

# where to send error messages to
server.errorlog = “/var/log/lighttpd.error.log”

# accesslog module
accesslog.filename = “/var/log/lighttpd.access.log”

#### scgi module
scgi.server = ( “/” =>
(

“192.168.2.132” => (
“host” => “127.0.0.1”,
“port” => 4000,
“min-procs” => 1,
“max-procs” => 2,
“check-local” => “disable”)

))

The Pylons configuration file, production.ini:

[server:main]
use = egg:Paste#http

#Use SCGI threaded
[server:main]
use = egg:PasteScript#flup_scgi_thread
host = 127.0.0.1
port = 4000

Thats it! Now start up the servers. Lighttpd runs on port 80, where visitors connect to, where it communicates with the 127.0.0.1:4000 Pylons application.

# /usr/local/sbin/lighttpd -f /usr/local/etc/lighttpd.conf
# paster serve production.ini

Advertisements

4 Responses to “Pylons + lighttpd + SCGI”

  1. kim byung geon Says:

    server.document-root = “/opt/Entic/entic”

    /opt/Entic/entic is pylons public directory???

  2. Anil Says:

    /opt/Entic/entic is where the models, lib, public… reside in.

  3. kim byung geon Says:

    thanks~

  4. Sam Donaldson Says:

    Anil, thanks for this. Quick question…As asked before, I need to make sure that lightty serves up the static content, so should I set my document root to point to public in my pylons directory structure? Also, in the rule:

    scgi.server = ( “/” =>
    (

    “192.168.2.132″ => (
    “host” => “127.0.0.1″,
    “port” => 4000,
    “min-procs” => 1,
    “max-procs” => 2,
    “check-local” => “disable”)

    ))

    You have 192.168.2.132 => …, what exactly is that doing? Also, what error did you see in my scgi rules fi any?

    Thanks for your help.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: