[英]Python Flask app on AWS EC2
I have a Python Flask app structured as from home/Application/demo directory 我有一个从主目录/应用程序/演示目录构建的Python Flask应用程序
src > controller > ( views.py, templates > index.html ) src>控制器>(views.py,模板> index.html)
views.wsgi views.wsgi
views.wsgi views.wsgi
import sys
sys.path.insert(0, 'Applications/demo/src/controller')
from views import app as application
views.py views.py
from flask import Flask
app = Flask(__name__)
if __name__ == '__main__':
app.run(debug=True)
Inside /etc/apache2/sites-available , I created a conf file named mysite.conf with content - 在/ etc / apache2 / sites-available内部,我创建了一个名为mysite.conf的conf文件,其内容为-
<VirtualHost *:80>
WSGIDaemonProcess views
WSGIScriptAlias / /Applications/demo/views.wsgi
<Directory /Applications/demo/src/controller>
WSGIProcessGroup views
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
</VirtualHost>
And ran these commands - 并运行这些命令-
sudo a2dissite 000-default.conf
sudo a2ensite mysite.conf
sudo /etc/init.d/apache2 restart
When I restart apache and go to the page, I get 当我重新启动apache并转到页面时,我得到
Forbidden
禁止的
You don't have permission to access / on this server.
您无权访问此服务器上的/。
Should be: 应该:
<Directory /Applications/demo>
WSGIProcessGroup views
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
That is, the directory where the WSGI script file referred to by WSGIScriptAlias
is, not where the modules that then imports are. 即,
WSGIScriptAlias
引用的WSGI脚本文件所在的目录,而不是随后导入的模块所在的目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.