我在linux服务器配置上做我的项目,在亚马逊轻轨上使用ubuntu。我安装了python2.7.5并安装了python 3我通过更改别名将其更改为python 3,因为我的应用程序在python3上。
我的wsgi服务器配置如下
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")
from FlaskApp import app as application
application.secret_key = 'Add your secret key'
我的配置文件如下
<VirtualHost *:80>
ServerName 52.24.125.53
ServerAdmin [email protected]
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
当我尝试通过IP地址访问时,它显示内部错误500
以下是错误日志
[Mon Sep 10 15:53:22.843424 2018] [wsgi:error] [pid 3620:tid 140263087400704] [client 103.211.114.174:27167] from flask import Flask, render_template
[Mon Sep 10 15:53:22.843450 2018] [wsgi:error] [pid 3620:tid 140263087400704] [client 103.211.114.174:27167] ImportError: No module named 'flask'
[Mon Sep 10 15:53:23.421818 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] mod_wsgi (pid=3619): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.421875 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] mod_wsgi (pid=3619): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.421968 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] Traceback (most recent call last):, referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.421991 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.421995 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] from FlaskApp import app as application, referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.422001 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] File "/var/www/FlaskApp/FlaskApp/__init__.py", line 1, in <module>, referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.422004 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] from flask import Flask, render_template, referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.422019 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] ImportError: No module named 'flask', referer: http://18.222.248.66/
我已经在python3和python2.7.5包上安装了所有模块。但仍然显示导入错误。我认为它与wsgi的问题。我是新手,请帮助解决问题。
您需要在应用中检查模块名称
我认为您导入了模块名称“from flask import flask”。
(要么)
你需要安装烧瓶
pip install Flask