python– 尝试使用mod_wsgi设置flask

python– 尝试使用mod_wsgi设置flask,第1张

概述我正在尝试使用mod_wsgi设置烧瓶,但我一直收到以下错误(13)Permission denied: access to / denied (filesystem path '/home/ec2-user/myapp') because search permissions are missing on a component of the path t

我正在尝试使用mod_wsgi设置烧瓶,但我一直收到以下错误

(13)Permission denIEd: access to / denIEd (filesystem path '/home/ec2-user/myapp') because search permissions are missing on a component of the path

test是烧瓶app中的有效路线.
这是我在/etc/httpd/conf.d文件夹中的myapp.conf文件

WsgiRestrictStdout Off

这是带有python 2.6.8的Apache / 2.2.26
我没有使用virtualenv.

当我启动apache时,我在error_log中看到这个通知

[Mon Feb 10 14:33:00 2014] [notice] Apache/2.2.26 (Unix) DAV/2 mod_wsgi/3.2 Python/2.6.8 configured -- resuming normal operations

这是我的myapp.wsgi文件

from flask import Flaskapplication = Flask(__name__)@application.route("/")def hello():    return "Hello World!"if __name__ == "__main__":    application.run(host='0.0.0.0',port=80)

只运行python myapp.wsgi工作正常

错误似乎告诉我,我应该更改某些文件夹的一些权限,但我不知道什么文件夹.

最佳答案您应该查看13PermissionDenied的Apache文档,并确保为您的文件夹设置了正确的权限.

chmod 755 /home/ec2-user/myapp/

你也可以:

cd /home/ec2-user/ls -la 

这将输出每个文件和所有者:文件夹的每个用户组的组和权限.寻找与众不同的东西.

从WSGIDaemonProcess docs开始:

user=name | user=#uID.rst

defines the UNIX user name or numeric user uID of the user that the daemon processes should be run as. If this option is not supplIEd the daemon processes will be run as the same user that Apache would run child processes and as defined by the User directive.

Note that this option is ignored if Apache wasn’t started as the root user,in which case no matter what the settings,the daemon processes will be run as the user that Apache was started as.

如果您以apache身份运行您的用户,它将不会以ec2-user身份运行,并且apache用户必须能够访问所有子目录和包含文件夹/ home / ec2-user /.

您可以移动到/ var / www /,chown到用户apache并从那里运行,因此您不必移动ec2-users主目录的权限.

总结

以上是内存溢出为你收集整理的python – 尝试使用mod_wsgi设置flask全部内容,希望文章能够帮你解决python – 尝试使用mod_wsgi设置flask所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/1207852.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)