使用FastCGI

时间:2016-09-17 22:18:58

标签: python plone fastcgi wsgi flup

我试图用WSGI和FastCGI部署Plone 5。根据官方Plone 5文档中的link,Plone 5支持使用WSGI进行部署。我可以根据上面的链接成功运行bin/paste serve zope.wsgi,并查看Plone 5主页。

下一步是使用flup包装WSGI应用程序,使其与FastCGI兼容。我创建了两个文件:

dispatch_fcgi.py:

#!/usr/bin/env python
ve = '/home/xxx/Plone/zinstance'

import site
site.addsitedir(ve+'/eggs')

from flup.server.fcgi import WSGIServer
from paste.deploy import loadapp

wsgi_app = loadapp('config:'+ve+'/zope.wsgi')

if __name__ == '__main__':
    WSGIServer(wsgi_app).run()

dispatch.fcgi:

#!/bin/bash
this_dir=`dirname $0`

export HOME=/home/xxx
source "$HOME/Plone/zinstance/bin/activate"

err_log_file="${this_dir}/../logs/dispatch_err.log"
exec python "${this_dir}/dispatch_fcgi.py" "$@" 2>>"${err_log_file}"

.htaccess将所有请求重定向到dispatch.fcgi,这会设置所有环境并将参数传递给dispatch_fcgi.py。然后,后者使用Paste加载WSGI配置文件,并运行它。

理想情况下,它应该与使用./bin/paste serve zope.wsgi运行完全相同。但是,它显示了默认的Zope页面,我无法访问ZMI,因为它一直在询问我的密码(我可以使用paste serve访问它)。此外,网址很奇怪,例如“http://xxxxxx/dispatch.fcgi/manage”,其中dispatch.fcgi不应该是其中的一部分。

在执行./bin/paste serve zope.wsgi并在脚本中运行paste时,知道行为有何不同?

更新:.htaccess

Options +ExecCGI
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteRule   ^(dispatch\.fcgi/.*)$  - [QSA,L]
RewriteRule   ^(.*)$  dispatch.fcgi/$1 [QSA,L]

0 个答案:

没有答案