我想在AWS EC2上部署flask app。但我遇到 500内部服务器错误。
首先,我安装了apache webserver和mod_wsgi。
$ sudo apt-get update
$ sudo apt-get install apache2
$ sudo apt-get install libapache2-mod-wsgi
$ sudo apt-get install libapache2-mod-wsgi-py2
我已经安装了pip3和烧瓶。
$ sudo apt-get install python3-pip
$ sudo pip3 install flask
这是flaskapp目录中的flask.wsgi文件。
import sys
sys.path.insert(0, '/var/www/html/flaskapp')
from flaskapp import app as application
我已经启用了mod_wsgi。
WSGIDaemonProcess flaskapp threads=5
WSGIScriptAlias / /var/www/html/flaskapp/flaskapp.wsgi
<Directory flaskapp>
WSGIProcessGroup flaskapp
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
最后,我重新启动了apache2。
$ sudo apachectl restart
当我访问AWS EC2域时,我收到 500内部服务器错误。
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
我的flaskapp应该在python3上运行。
我不知道如何处理这个问题。
答案 0 :(得分:0)
类似的问题一直是answered before。
引用答案:
问题本质上是你在虚拟环境中安装Flask,可能还有其他必需的库,但是python(wsgi接口)运行的系统python没有安装这些额外的库。
显然,处理此问题的一种方法是使用
plt.xlim(-1,13)
包将venv中的site
添加到执行的Python中。这将放在您的site-packages
文件中。
.wsgi