1

我正在尝试在通过 xampp 运行的 apache 服务器上运行带有 mod_wsgi 的烧瓶应用程序。我已经尝试阅读所有已经提出的问题并浏览了 wsgi 的 wiki,但我似乎仍然无法找到我收到此错误的原因。我在使用 python 2.6.6 我的 httpd.conf 的 debian 6 上:

WSGIDaemonProcess debug_tool user=spyglass group=root threads=5
WSGIScriptAlias /debug_tool /opt/lampp/htdocs/spyglass_v2/debug_tool/debug_tool.wsgi
<Directory /opt/lampp/htdocs/spyglass_v2/debug_tool>
  WSGIProcessGroup debug_tool
  WSGIApplicationGroup %{GLOBAL}
  Order deny,allow
  Allow from all
</Directory>

我的 debug_tool.wsgi:

import sys
sys.path.insert(0,"/opt/lampp/htdocs/spyglass_v2/debug_tool/")
from debug_tool import app as application

我的 debug_tool 文件夹如下所示:

ls -rtl
total 32
drwxr-xr-x 2 root     root 4096 Dec 18 19:36 uploads
drwxr-xr-x 2 root     root 4096 Dec 18 19:36 Testing_Paramerters
drwxr-xr-x 2 root     root 4096 Dec 18 19:36 templates
-rw-r--r-- 1 root     root 4688 Dec 19 14:42 debug_tool.py
-rw-r--r-- 1 spyglass root 3859 Dec 19 14:43 debug_tool.pyc
-rw-r--r-- 1 spyglass root  118 Dec 19 15:17 debug_tool.wsgi

我的 deubg_tool.py 看起来像这样:

import os
import re
from flask import Flask, request, redirect, url_for, render_template

app = Flask(__name__)
app.debug = True

@app.route('/',methods=['GET'])
def hello_world():

return 'hello world'

你知道有什么问题吗?

更新:

当我尝试导入烧瓶时,我明白了。这意味着什么?

错误日志:

[Thu Dec 20 12:09:49 2012] [error] [client 172.20.31.135] 脚本头过早结束:debug_tool.wsgi [Thu Dec 20 12:09:49 2012] [notice] child pid 20206 exit signal Segmentation fault (11)

并且 python 脚本在实际文件中正确缩进。它可以很好地导入 re 和 os,但是一旦我尝试导入烧瓶,我就会收到该错误

我查看了我的 httpd.conf 文件,我正在加载 mod_php5。是否可以同时运行?我去了 http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive 但无法弄清楚如何运行这两个模块。

我的总体目标是使用 mod_wsgi 将此工具添加到运行 mod_php5 的现有服务器中。谢谢

4

1 回答 1

0

根据我的经验,由于异常,脚本头的过早结束几乎总是堆栈跟踪。

由于您还没有足够大的项目来进行日志记录,因此我建议您将所有内容简单地包装在一个 try-except 打印到 stderr


try:
  YOUR SCRIPT CONTENTS HERE
except Exception, ex:        
  import sys

  from traceback import format_list, extract_tb

  (extype, value, trace) = sys.exc_info()

  print >> sys.stderr, "%s:%s\n%s" % (extype, value, ''.join(format_list(extract_tb(trace))))

然后检查 apache 日志中的输出,这些输出可能位于

/var/log/httpd/error_log

于 2013-08-30T16:10:46.120 回答