PylonsHQ.

Layout: Fixed-width

Running Pylons with SCGI and Lighttpd

Unknown macro: {metadata-list}
Name Running Pylons with SCGI and Lighttpd
Space Pylons Cookbook
Section Deployment
Page Running Pylons with SCGI and Lighttpd
Version 1.0
Status Draft
Reviewed False
Author(s) 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:Flup#scgi_thread
host = 127.0.0.1
port = 6500
scriptName = ""
...

You may customize the port to whatever you prefer
Set scriptName to "" if your application lies on the root of the server. If in the lighttpd configuration you change where the root of your application is, then you must reflect that change in scriptName.

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

If you were to set the root of the application to something other than "/", then be sure to reflect this in scriptName above. So if you set this to "/test", set scriptName to "/test".

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.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Powered by Pylons - Contact Administrators