加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 尝试使用mod_wsgi设置flask

发布时间:2020-12-16 23:53:09 所属栏目:Python 来源:网络整理
导读:我正在尝试使用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中的有效路线. 这是我在/et

我正在尝试使用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 Flask
application = 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主目录的权限.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读