我创建了一个单文件 Flask 应用程序,因此我可以测试如何在 apache2 服务器上部署它。就服务器和 WSGI 配置而言,我遵循了Flask上的步骤。当我指向浏览器中的资源时,它说我没有权限。WSGI 守护进程被赋予与 Flask 应用程序相同的权限。下面是 VirtualHost 配置。
<VirtualHost *:80>
ServerName localhost
WSGIDaemonProcess flask_test user=someuser group=someuser threads=5
WSGIScriptAlias /flask_test/ /var/www/flask_test/flask_test.wsgi
DocumentRoot /var/www/flask_test/
ErrorLog /var/www/flask_test/logs/error.log
<Directory /var/www/flask_test/>
WSGIProcessGroup flask_test
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Order deny,allow
Deny from all
</Directory>
</VirtualHost>
这是WSGI文件
import sys
activate_this = '/home/someuser/pyProjects/general/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
sys.path.append('/home/someuser/pyProjects')
from general import test as application
最后是 error.log 的输出
[Tue Jul 31 01:51:18 2012] [error] Exception KeyError: KeyError(140345719740224,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Tue Jul 31 01:51:21 2012] [error] [client 108.207.222.48] client denied by server configuration: /var/www/flask_test/flask_test.wsgi
[Tue Jul 31 01:51:21 2012] [error] [client 108.207.222.48] client denied by server configuration: /var/www/flask_test/favicon.ico
编辑:实施 Graham Dumpleton 建议服务器后,现在返回代码 500 并出现以下错误
TypeError: 'module' object is not callable