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

Advertisement