试图用mod_wsgi设置瓶子 [英] Trying to set up flask with mod_wsgi

查看:220
本文介绍了试图用mod_wsgi设置瓶子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 (13)权限被拒绝:访问/拒绝(文件系统路径'/ home / ec2-user / myapp'),因为路径的组件上缺少搜索权限

这是我的 myapp.conf $ b

/ code>在 /etc/httpd/conf.d 文件夹中的文件

  WSGIRestrictStdout Off 
< VirtualHost *>
ServerName somewhere.compute-1.amazonaws.com

WSGIDaemonProcess flaskapp user = ec2-user group = ec2-user threads = 5
WSGIScriptAlias // home / ec2-user / myapp / myapp.wsgi

< Directory / home / ec2-user / myapp>
WSGIProcessGroup flaskapp
WSGIApplicationGroup%{GLOBAL}
命令拒绝,允许
允许所有的
< / Directory>
LogLevel通知
< / VirtualHost>

这是 Apache / 2.2.26 python 2.6.8

我没有使用virtualenv。



在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  - 恢复正常操作

是我的 myapp.wsgi 文件

  from flask import Flask 
application = Flask(__ name__)

@ application.route(/)
def hello():
returnHello World!

if __name__ ==__main__:
application.run(host ='0.0.0.0',port = 80)
$ b $ p

运行 python myapp.wsgi 可以正常工作



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

解决方案

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

  chmod 755 / home / ec2-user / myapp / 

您也可以:

  cd / home / ec2-user / 
ls -la

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



WSGIDaemonProcess docs


user = name | user =#uid.rst

定义守护程序进程应运行的用户的UNIX用户名或数字用户uid。如果没有提供这个选项,守护进程将以Apache用户运行子进程的相同用户的身份运行,并由用户指令定义。



请注意,如果Apache没有以root用户身份启动,这个选项将被忽略。在这种情况下,无论设置如何,守护进程都将以Apache启动的用户身份运行。


如果将用户作为 apache 运行,则不会以 ec2-user apache 用户必须有权访问所有子目录,包含文件夹 / home / ec2-user / 。



您可以移至 / var / www / chown 到用户 apache 并从那里运行,所以您不必移动 ec2-用户的主目录。

I'm trying to set up flask with mod_wsgi but I keep getting following error

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

test is a valid route in the flask app.
This is my myapp.conf file in the /etc/httpd/conf.d folder

WSGIRestrictStdout Off
<VirtualHost *>
    ServerName somewhere.compute-1.amazonaws.com

    WSGIDaemonProcess flaskapp user=ec2-user group=ec2-user threads=5
    WSGIScriptAlias / /home/ec2-user/myapp/myapp.wsgi

    <Directory /home/ec2-user/myapp>
        WSGIProcessGroup flaskapp
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
    LogLevel notice
</VirtualHost>

This is Apache/2.2.26 with python 2.6.8
I am not using virtualenv.

When i start apache i see this as notice in the 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

This is my myapp.wsgi file

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)

running just python myapp.wsgi works fine

The error seems to tell me i should change some permissions on some folder, but I have no idea what folder.

解决方案

You should check out the Apache docs for 13PermissionDenied and make sure that you set the correct permissions for your folder.

chmod 755 /home/ec2-user/myapp/

You can also:

cd /home/ec2-user/
ls -la 

Which will output every file and the owner:group and permissions for each user group of your folder. Look for anything out of the ordinary.

From the 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.

If you're running your user as apache it will not be running as ec2-user and the apache user must have access to all subdirectories and the containing folder /home/ec2-user/.

You could move to /var/www/, chown to user apache and run from there so you don't have to move the permissions of the ec2-users home directory.

这篇关于试图用mod_wsgi设置瓶子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆