mod\wsgi python conf pars模块

2024-10-04 09:22:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我设置了Flask,这是一个pythonweb微框架,位于apache和mod wsgi下。在

除了python confparser之外,该应用程序运行良好。这不会出错:

parser = ConfigParser.ConfigParser()
parser.read('snati.con')

但当我加上:

^{pr2}$

我得到了内部服务器错误错误.log阿帕奇的

我也试过:

file = open("sample.txt")

同样的结果。在

一定有一些配置问题,但我找不到。在

我的apache conf看起来像:

WSGIRestrictStdout Off

<VirtualHost *:80>
    ServerName my.com

    WSGIDaemonProcess myapp user=me group=me threads=5

    WSGIScriptAlias / /home/me/www/myapp.wsgi

    <Directory /home/me/www/myapp >
        WSGIProcessGroup myapp
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

我的应用程序.wsgi在

#active the python virtualenv for this application
activate_this = '/home/gilles/www/snati/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))


import sys
sys.path.insert(0, '/home/gilles/www/snati/src')
sys.stdout = sys.stderr

from app import app as application

什么可能是错误的?为什么我不能在Apache日志中得到错误?在


Tags: parserwsgihomeapachewww错误systhis
2条回答

将路径添加到带有home变量的apache设置文件中

WSGIDaemonProcess myapp user=me group=me threads=5 home=/path/to/your/directory

这将更改进程的工作目录。在

使用Python代码中文件的绝对路径,而不是相对路径。在

进程的当前工作目录将不在应用程序代码和文件所在的位置。在

您没有看到任何错误,因为如果不在调试模式下,Flask将不会记录这些错误。设置应用程序来捕获它们并发送电子邮件或以其他方式记录它们。我不记得Flask有什么选择。在

相关问题 更多 >