我想在AWS EC2上部署flask应用程序。但是我遇到了500内部服务器错误。如何在AWS EC2上部署flask应用程序 - 内部服务器错误?
首先,我已经安装了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 [email protected] 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上运行。
我不知道如何处理这个问题。
你有没有看你的Django应用程序日志或Apache日志,这或许是在'/无功/日志/ apache'或'/无功/日志/ httpd'? – birryree
感谢您的回复。 '/ var/log/apache2/error.log'中没有任何内容。 '/ var/log'目录中没有httpd目录。 –
这可能表明问题来自'wsgi'模块,并且由于Apache默认为“警告”级日志记录,所以它会抑制日志输出。尝试在你的'httpd.conf'中设置'LogLevel info'来在日志中显示更多的消息。 – birryree