部署烧瓶时如何处理apache导入错误?

时间:2015-05-28 02:56:40

标签: apache python-2.7 flask wsgi

我试图将烧瓶部署到运行Amazon Linux的aws EC2实例无济于事。我在全局和虚拟环境中安装了烧瓶。我不确定我做错了什么。尝试访问我的网站时,我收到内部服务器错误,指出:服务器遇到内部错误或配置错误,无法完成您的请求。在挖掘日志时,我看到以下内容:

[Thu May 28 02:25:27 2015] [error] [client 45.160.040.111]     from flask import Flask, render_template,redirect,request,url_for, flash, session
[Thu May 28 02:25:27 2015] [error] [client 45.160.040.111] ImportError: No    module named flask
[Thu May 28 02:25:28 2015] [error] [client 45.160.040.111] mod_wsgi (pid=1565): Target WSGI script '/var/www/Foodie-Web-Application/foodie/app.wsgi' cannot be loaded as Python module.
[Thu May 28 02:25:28 2015] [error] [client 45.160.040.111] mod_wsgi (pid=1565): Exception occurred processing WSGI script '/var/www/Foodie-Web-Application/foodie/app.wsgi'.
[Thu May 28 02:25:28 2015] [error] [client 45.160.040.111] Traceback (most recent call last):
[Thu May 28 02:25:28 2015] [error] [client 45.160.040.111]   File "/var/www/Foodie-Web-Application/foodie/app.wsgi", line 9, in <module>
[Thu May 28 02:25:28 2015] [error] [client 45.160.040.111]     from routes import app  as application
[Thu May 28 02:25:28 2015] [error] [client 45.160.040.111]   File "/var/www/Foodie-Web-Application/foodie/app/routes.py", line 1, in <module>
[Thu May 28 02:25:28 2015] [error] [client 45.160.040.111]     from flask import Flask, render_template,redirect,request,url_for, flash, session
[Thu May 28 02:25:28 2015] [error] [client 45.160.040.111] ImportError: No module named flask

这是我的wsgi文件:

activate_this = '/var/www/Foodie-Web-Application/foodie_venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
sys.path.insert(0, '/var/www/Foodie-Web-Application/foodie/app')
from routes import app  as application

我的配置文件:

<VirtualHost *:80>
        ServerName ec2-56-24-1990-35662.us-west-2.compute.amazonaws.com
          WSGIDaemonProcess app
     WSGIScriptAlias / /var/www/Foodie-Web-Application/foodie/app.wsgi

     <Directory /var/www/Foodie-Web-Application/foodie/app>
            WSGIProcessGroup app
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
     </Directory>
</VirtualHost>

这是文件结构:

/var/www/Foodie-Web-Application:
   /foodie_venv #virtual environment: flask is also installed here
   /foodie 
     /app #The Flask App
        app.py
        search_results.py
        yes.py
       /static
       /templates

0 个答案:

没有答案