继续研究尝试 ::-- ZoomQuiet [DateTime(2007-03-06T14:14:46Z)] TableOfContents

1. apache+fastcgi

1.1. 准备

{{{#确保以下模块安装成功 LoadModule dav_module libexec/apache22/mod_dav.so LoadModule dav_svn_module libexec/apache22/mod_dav_svn.so LoadModule authz_svn_module libexec/apache22/mod_authz_svn.so

LoadModule python_module libexec/apache22/mod_python.so LoadModule fastcgi_module libexec/apache22/mod_fastcgi.so }}}

1.2. 51boo方式

import sys, os sys.path = [,

# Set the DJANGO_SETTINGS_MODULE environment variable. os.environ['DJANGO_SETTINGS_MODULE'] = "settings"

from django.core.servers.fastcgi import runfastcgi runfastcgi(["method=threaded", "daemonize=false", "pidfile=pidfile"]) }}}

<VirtualHost *:80>
    ServerName obp.zoomquiet.org
...
    RewriteEngine On
    #RewriteBase /
    RewriteLogLevel 1
    RewriteLog "/var/log/httpd/rewrite.log"
    
    Alias /openbookplatform "/usr/local/www/data/obp/trunk/openbookplatform"
    <Directory "/usr/local/www/data/obp/trunk/openbookplatform">
        AddHandler fcgid-script .fcgi
        Options +FollowSymLinks +ExecCGI
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]
    </Directory>   

1.2.1. 结果

重启 apache 成功

Forbidden

You don't have permission to access /openbookplatform on this server.
  • 直接运行django.fcgi

     ./django.fcgi
    WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
    WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
    WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
    WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
    Traceback (most recent call last):
      File "/usr/local/lib/python2.4/site-packages/flup-0.5-py2.4.egg/flup/server/fcgi_base.py", line 558, in run
        protocolStatus, appStatus = self.server.handler(self)
      File "/usr/local/lib/python2.4/site-packages/flup-0.5-py2.4.egg/flup/server/fcgi_base.py", line 1112, in handler
        result = self.application(environ, start_response)
      File "/usr/local/lib/python2.4/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
        response = self.get_response(request)
      File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py", line 59, in get_response
        response = middleware_method(request)
      File "/usr/local/lib/python2.4/site-packages/django/middleware/common.py", line 41, in process_request
        if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]):
    IndexError: string index out of range
    Content-Type: text/html
  • 怀疑是定制过 Djnago 的和 官方文档没有相类之处,先放下

1.3. Django 方式

{{{#!/bin/bash

# Replace these three settings. PROJDIR="/usr/local/www/data/obp/trunk/openbookplatform" PIDFILE="$PROJDIR/obp.pid" SOCKET="$PROJDIR/obp.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 }}}

  • 配置apache

FastCGIExternalServer /usr/local/www/data/obp/trunk/openbookplatform/obp.fcgi -host 127.0.0.1:3033
<VirtualHost *:80>
    ServerName obp.zoomquiet.org
...
    RewriteEngine On
    #RewriteBase /
    RewriteLogLevel 1
    RewriteLog "/var/log/httpd/rewrite.log"
    RewriteRule ^/(media.*)$ /usr/local/www/data/obp/trunk/openbookplatform/media/$1 [QSA,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^/(.*)$ /obp.fcgi/$1 [QSA,L]
...

1.3.1. 结果

重启 apache 成功

Not Found

The requested URL / was not found on this server.

1.4. 继续试探

  • 尝试修订 obp.fcgi{{{#!/bin/sh

# Replace these three settings. PROJDIR="/usr/local/www/data/obp/trunk/openbookplatform" PIDFILE="$PROJDIR/obp.pid" SOCKET="$PROJDIR/obp.sock" if [ -f $PIDFILE ]; then kill cat -- $PIDFILE rm -f -- $PIDFILE fi /usr/local/bin/python \ ./manage.py runfcgi socket=$SOCKET pidfile=$PIDFILE }}}

  • 可以直接运行{{{$ sockstat

... zoomq python 51196 3 stream /usr/local/www/data/obp/trunk/openbookplatform/obp.sock zoomq python 51196 4 stream -> ?? zoomq python 51195 3 stream /usr/local/www/data/obp/trunk/openbookplatform/obp.sock zoomq python 51195 4 stream -> ?? zoomq python 51194 3 stream /usr/local/www/data/obp/trunk/openbookplatform/obp.sock zoomq python 51194 4 stream -> ?? zoomq python 51193 3 stream /usr/local/www/data/obp/trunk/openbookplatform/obp.sock zoomq python 51193 4 stream -> ?? zoomq python 51192 3 stream /usr/local/www/data/obp/trunk/openbookplatform/obp.sock zoomq python 51192 4 stream -> ?? zoomq python 51191 3 stream /usr/local/www/data/obp/trunk/openbookplatform/obp.sock }}}

  • 成功!可以观察到{{{#sockstat

USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS zoomq python 50875 3 stream /home/zoomq/obp.sock zoomq python 50875 4 stream -> ?? zoomq python 50874 3 stream /home/zoomq/obp.sock zoomq python 50874 4 stream -> ?? zoomq python 50873 3 stream /home/zoomq/obp.sock zoomq python 50873 4 stream -> ?? zoomq python 50872 3 stream /home/zoomq/obp.sock zoomq python 50872 4 stream -> ?? zoomq python 50871 3 stream /home/zoomq/obp.sock zoomq python 50871 4 stream -> ?? zoomq python 50870 3 stream /home/zoomq/obp.sock }}}

  • 修订apache

    FastCGIExternalServer /usr/local/www/data/obp/trunk/openbookplatform/obp.fcgi -socket /usr/local/www/data/obp/trunk/openbookplatform/obp.sock
    <VirtualHost 210.192.102.145:80>
        ServerName obp.zoomquiet.org
        DocumentRoot /usr/local/www/data/obp/trunk/openbookplatform
    ...
  • 结果重启成功,访问 http://obp.zoomquiet.org/

    Forbidden
    
    You don't have permission to access / on this server
  • 观察 rewrite.log

    61.135.152.194 - - [06/Mar/2007:22:47:18 +0800] [obp.zoomquiet.org/sid#8148ce8][rid#82e1050/initial] (1) go-ahead with /usr/local/www/data/obp/trunk/openbookplatform/obp.fcgi/ [OK]
    是成功的....

2. 反馈

PageComment2