【问题标题】:PHP Beanstalk with laravel permission denied on storage/framework/cache具有 laravel 权限的 PHP Beanstalk 在存储/框架/缓存上被拒绝
【发布时间】:2016-02-15 21:27:08
【问题描述】:

我已经使用 Amazing Beanstalk 部署了我的 Laravel 5.1 应用程序,经过反复使用,我最终得到了这个错误。

"file_put_contents(/var/app/current/storage/framework/cache/d4/d7/d4d77eddeb64100f6da8f8b601a4631b): failed to open stream: Permission denied"

在我的 .ebextensions 配置文件中,我尝试将此命令添加到部署中,但它并没有解决问题,因为文件似乎是在部署后在浏览站点时创建的。

container_commands:
  "02-chmod-storage":
    command: "cd /var/app/ondeck;  chmod -R 777 storage"

我怎样才能永久解决这个问题?

【问题讨论】:

    标签: php linux laravel amazon-web-services amazon-elastic-beanstalk


    【解决方案1】:

    应该这样做:

    commands:
      create_post_dir:
        command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
        ignoreErrors: true
    files:
      "/opt/elasticbeanstalk/hooks/appdeploy/post/99_chmod_storage.sh":
        mode: "000755"
        owner: root
        group: root
        content: |
          #!/usr/bin/env bash
          . /opt/elasticbeanstalk/support/envvars
          cd $EB_CONFIG_APP_CURRENT
          su -c "chmod -R 777 storage" $EB_CONFIG_APP_USER
    

    【讨论】:

      【解决方案2】:

      尝试在 /storage 上设置 ACL 权限,允许 root 和 webapp(或正在运行的 Web 服务器的用户名)进行 rwx 访问:

      files:
        "/opt/elasticbeanstalk/hooks/appdeploy/post/99_setfacl_storage.sh":
          mode: "000755"
          owner: root
          group: root
          content: |
            #!/usr/bin/env bash
            echo "Setting ACL permissions for /storage..."
            setfacl -Rdm u:root:rwx,u:webapp:rwx /var/app/current/storage
            setfacl -Rm u:root:rwx,u:webapp:rwx /var/app/current/storage
      

      【讨论】:

        猜你喜欢
        • 2019-06-13
        • 2019-07-16
        • 2021-12-18
        • 2016-06-13
        • 2021-11-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多