部署flask和apache2 mod_wsgi的问题

时间:2015-10-17 08:57:24

标签: python apache flask mod-wsgi

我只关注他们在doc中所说的一切,但还没弄清楚为什么apache2会抛出错误。

root@Test1:/etc/apache2/sites-available# tail -5 /var/log/apache2/error.log 
[Sat Oct 17 04:22:13.518858 2015] [core:notice] [pid 28379] AH00094: Command line: '/usr/sbin/apache2'
[Sat Oct 17 04:22:18.930540 2015] [:error] [pid 28573] [client 223.190.213.33:33891] mod_wsgi (pid=28573): Exception occurred processing WSGI script '/var/www/instanotify/instanotify.wsgi'.
[Sat Oct 17 04:22:18.930623 2015] [:error] [pid 28573] [client 223.190.213.33:33891] TypeError: 'module' object is not callable
[Sat Oct 17 04:43:26.664459 2015] [:error] [pid 28575] [client 223.190.213.33:34215] mod_wsgi (pid=28575): Exception occurred processing WSGI script '/var/www/instanotify/instanotify.wsgi'.
[Sat Oct 17 04:43:26.664634 2015] [:error] [pid 28575] [client 223.190.213.33:34215] TypeError: 'module' object is not callable

更新:

root@Test1:/var/www/instanotify# cat instanotify.wsgi 
#!/usr/bin/python
import sys
import logging
# Virutalenv activattion
activate_this = '/var/www/instanotify/instanotify/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/instanotify/")

from instanotify import app as application
application.secret_key = 'Add your secret key'

如果我删除了virtualenv激活行,我将获得no module named flask

有人知道如何解决......!我很乐意提供进一步的信息

1 个答案:

答案 0 :(得分:0)

您没有导入实际的app文件......正确的方法是

from instanotify.app import app as application