使用Apache Web服务器更改Flask应用程序中的默认权限

时间:2014-11-07 22:26:36

标签: python apache permissions flask file-permissions

我有一个使用此代码创建目录的烧瓶应用程序:

if not os.path.exists(target_path):
    os.makedirs(target_path)

使用创建的目录,默认权限为0755,所有者和组为_www。 因此,只有所有者才能在目录中写入。

我总是需要手动将权限修改为0775以在其中创建一些文件。

enter image description here

如何将默认目录权限设为0775?我使用apache进行Web服务器。

2 个答案:

答案 0 :(得分:1)

这与Apache设置有关。

对于Mac:

  1. 打开/System/Library/LaunchDaemons/org.apache.httpd.plist
  2. 添加<key>Umask</key><integer>002</integer>
  3. 使用sudo apachectl restart
  4. 重新启动

    我找到了来自this site的解决方案,对于linux我猜Setting the umask of the Apache user可以提供一些提示。

答案 1 :(得分:0)

将代码更改为

if not os.path.exists(target_path):
    os.makedirs(target_path, mode=0775)