使用 mod_fcgid 在 Apache 上部署 Pylons

使用 mod_fcgid 在 Apache 上部署 Pylons

我尝试使用找到的说明部署我的 Pylons 应用程序这里。当我访问我的域的根目录时,这只会加载默认的 Pylons 页面。当我尝试输入任何路径时,我都会收到消息

Unhandled Exception

An unhandled exception was thrown by the application.

当我查看应用程序的错误日志和 Apache 错误日志时,似乎 Pylons 总是尝试将事情路由到错误控制器。但是,请注意,上述消息不是我的错误控制器应该输出的内容。

有什么建议可以检查什么吗?我喜欢用 Pylons 进行开发,但这是我第一次尝试部署。我在多个不同的 Web 服务器上尝试了多种配置,但都没有成功。

更新:以下是我的 Pylons 应用程序的配置(删除了注释以使其更短一些)

[DEFAULT]
smtp_server = localhost
error_email_from = paste@localhost

[server:main]
use = egg:PasteScript#flup_fcgi_thread

[app:main]
use = egg:linkdb
full_stack = true
static_files = true

cache_dir = %(here)s/data
beaker.session.key = linkdb
beaker.session.secret = b75f1813263ab9a082f67278daa26433

sqlalchemy.url = mysql://cclp:[email protected]/ccorl

authkit.setup.enable = True
authkit.setup.method = form, cookie
authkit.form.authenticate.user.type = linkdb.model.auth:MyUsersFromDatabase
authkit.form.authenticate.user.data = linkdb.model
authkit.cookie.secret = c2b47614b6eb46c4bd7842cae10f27e4
authkit.cookie.signoutpath = /users/logout
authkit.form.template.obj = linkdb.model.auth:make_template

set debug = false

[loggers]
keys = root, routes, linkdb, sqlalchemy

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = INFO
handlers = console

[logger_routes]
level = INFO
handlers =
qualname = routes.middleware

[logger_linkdb]
level = DEBUG
handlers =
qualname = linkdb

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

更新:这是应用程序生成的错误日志(我有点疑神疑鬼,所以我在 IP 地址上加了星号)

DEBUG:authkit.authenticate.cookie:These cookies were found: []
DEBUG:authkit.authenticate.cookie:Our cookie 'authkit' value is therefore ''
DEBUG:authkit.authenticate.cookie:Remote addr '***.***.***.***', value '', include_ip True
DEBUG:pylons.wsgiapp:Setting up Pylons stacked object globals
DEBUG:pylons.wsgiapp:No controller found, returning 404 HTTP Not Found
DEBUG:authkit.authenticate.multi:Status: '404 Not Found', Headers: [('Content-Type', 'text/html; charset=UTF-8'), ('Content-Length', '154')]
DEBUG:authkit.authenticate.multi:Status checker recieved status '404 Not Found', headers [('Content-Type', 'text/html; charset=UTF-8'), ('Content-Length', '154')], intecept ['401']
DEBUG:authkit.authenticate.multi:Status checker returns False
DEBUG:authkit.authenticate.multi:Multi: No binding was found for the check
DEBUG:authkit.authenticate.cookie:These cookies were found: []
DEBUG:authkit.authenticate.cookie:Our cookie 'authkit' value is therefore ''
DEBUG:authkit.authenticate.cookie:Remote addr '***.***.***.***', value '', include_ip True
DEBUG:pylons.wsgiapp:Setting up Pylons stacked object globals
DEBUG:pylons.wsgiapp:Resolved URL to controller: u'error'
DEBUG:pylons.wsgiapp:Found controller, module: 'linkdb.controllers.error', class: 'ErrorController'
DEBUG:pylons.wsgiapp:Controller appears to be a class, instantiating
DEBUG:pylons.wsgiapp:Calling controller class with WSGI interface

更新:这是我的应用程序正在使用的 fcgi 脚本

#!/usr/bin/env python
import logging
# Load the WSGI application from the config file
from paste.deploy import loadapp
wsgi_app = loadapp('config:/var/www/linkdb/production.ini')

# Deploy it using FastCGI
if __name__ == '__main__':
    logging.basicConfig(filename='/var/www/linkdb/error.log', level=logging.DEBUG)
    from flup.server.fcgi import WSGIServer
    WSGIServer(wsgi_app).run()

答案1

虽然您可以调试 fcgid 问题,但您可能会发现使用 mod_wsgi 进行部署要容易得多。

您可能遇到的问题与 .ini 文件中设置的 debug=true 有关,这在多线程模式下不起作用,或者与打印到 STDOUT 的代码有关。如果您可以发布更多配置、日志行等,应该很容易看出问题所在。根控制器内的操作是否被调用?您是否更改了路线?

您是否使用 virtualenv 来设置您的环境(go-pylons.py 安装程序?)或者您是否使用系统库并在根目录中执行 easy_install?

相关内容