| Name |
Space |
Section |
Page |
Version |
Status |
Reviewed |
Author(s) |
| Running Pylons with SCGI and Lighttpd |
Pylons Cookbook |
Deployment |
Running Pylons with SCGI and Lighttpd |
1.0 |
Draft |
False |
Ken Ingle |
 | This should be considered a work in progress, feel free to add/extend as necessary. |
Introduction
There are a multitude of ways to deploy Pylons applications on servers. This will document how to deploy a Pylons application with SCGI (a close brother to fastcgi) and Lighttpd (an extremely lightweight and fast web server).
Getting started
In order to complete this tutorial you will need to have flup and scgi installed. To install these:
$ easy_install -U flup
$ easy_install -U scgi
Setting up Pylons
When deploying an application to production you will want to create a production.ini file for use in that environment. This seperate .ini file gives you the opportunity to customize certain settings for production use (e.g. turning off debugging).
You will run the following command to create your production.ini file:
$ paster make-config projectname production.ini
Once you have created your production.ini you will need to make the following adjustments:
[DEFAULT]
debug = false
...
[server:main]
use = egg:PasteScript#flup_scgi_thread
host = 127.0.0.1
port = 6500
...
 | You may customize the port to whatever you prefer |
Setting up Lighttpd
Next you will need to configure Lighttpd to use mod_scgi and to then look for your application. Make the following adjustments to your lighttpd.conf
server.modules ("mod_scgi",....)
...
server.document-root = "/pathtoyourapplication"
...
scgi.server = ("/" =>
( "ServerIPAddress" => (
"host" => "127.0.0.1",
"port" => 6500,
"min-procs" => 1,
"max-procs" => 2,
"check-local" => "disable")
))
...
Wrapping it up
You have now completed the configuration for your application and Lighttpd. You simply need to start Lighttpd and your application:
$ sudo /etc/init.d/lighttpd start
$ paster serve production.ini
Closing
Hopefully this will assist you in configuring your application for use with Lighttpd. Feel free to email kingle at gmail.com with any quetions.