1
30
2010
0

Fedora下配置lighttpd+Django

这个blog的处女贴

1. 已有环境:

  • Fedora 12
  • Django project已配置好,位于 /var/www/django/mysite

2. 安装相关软件包:

sudo yum install python-flup lighttpd lighttpd-fastcgi 

3. 修改 /etc/lighttpd/lighttpd.conf 。中间省略了一大段,这只是最简单的配置

# lighttpd configuration file
#
# use it as a base for lighttpd 1.0.0 and above
#
# $Id: lighttpd.conf,v 1.7 2004/11/03 22:26:05 weigon Exp $

############ Options you really have to take care of ####################

## modules to load
# at least mod_access and mod_accesslog should be loaded
# all other module should only be loaded if really neccesary
# - saves some time
# - saves memory
## 去掉一些module的注释
server.modules              = (
                               "mod_rewrite",
                               "mod_redirect",
                               "mod_alias",
                                "mod_access",
#                               "mod_trigger_b4_dl",
#                               "mod_auth",
#                               "mod_status",
#                               "mod_setenv",
                               "mod_fastcgi",
#                               "mod_proxy",
#                               "mod_simple_vhost",
#                               "mod_evhost",
#                               "mod_userdir",
#                               "mod_cgi",
#                               "mod_compress",
#                               "mod_ssi",
#                               "mod_usertrack",
#                               "mod_expire",
#                               "mod_secdownload",
#                               "mod_rrdtool",
                                "mod_accesslog" )

## 省略了很多…………
## ………………………………

## include configuration snippets, usually provided by packages
include_shell "find /etc/lighttpd/conf.d -maxdepth 1 -name '*.conf' -exec cat {} \;"

## 加入以下内容
fastcgi.server = (
    "/mysite.fcgi" => (
        "main" => (
            # Use host / port instead of socket for TCP fastcgi
            #"host" => "127.0.0.1",
            #"port" => 8000,
            "socket" => "/tmp/mysite.sock",
            "check-local" => "disable",
        )
    ),
)

url.rewrite-once = (
    "^(/.*)$" => "/mysite.fcgi$1",
)

4. 创建快速运行脚本 /var/www/django/mysite/runfastcgi ,(其实放在哪里没所谓,)并添加执行权限

#!/bin/bash

# Replace these three settings.
PROJDIR="/var/www/django/mysite"
PIDFILE="$PROJDIR/django.pid"
SOCKET="/tmp/mysite.sock"

cd $PROJDIR
if [ -f $PIDFILE ]; then
kill `cat -- $PIDFILE`
rm -f -- $PIDFILE
fi

exec /usr/bin/env - \
PYTHONPATH="../python:.." \
./manage.py runfcgi socket=$SOCKET pidfile=$PIDFILE umask=000

5. 运行 lighttpd

sudo service lighttpd start

6. 访问 http://localhost/ ,大功告成

 

 

 参考: http://oteam.cn/2007/8/17/setting-lighttpd-django-on-ubuntu-server/

Category: Fedora | Tags: lighttpd fastcgi django

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com