【问题标题】:Laravel and AWS Elastic Beanstalk - File PermissionsLaravel 和 AWS Elastic Beanstalk - 文件权限
【发布时间】:2015-01-20 16:07:32
【问题描述】:

我创建了一个 Laravel 应用程序并使用 Elastic Beanstalk 将它部署到一个 EC2 实例。除了 PHP 无法写入 storage 目录之外,一切似乎都正常,所以我收到了这个错误:

Error in exception handler: The stream or file "/var/app/current/site/app/storage/logs/laravel.log" 
could not be opened: failed to open stream: 
No such file or directory in /var/app/current/site/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:84

这对我来说似乎是一个权限问题,所以我尝试使用http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html 的说明来设置权限。

我在.ebextensions 目录中有一个文件01permissions.config

commands:
  storage_permissions: 
    command: chmod -R 755 $EB_CONFIG_APP_ONDECK/site/app/storage

我在服务器日志中收到以下错误:

[ERROR] Command storage_permissions (chmod -R 755 $EB_CONFIG_APP_ONDECK/site/app/storage) failed
[DEBUG] Command storage_permissions output: chmod: cannot access ‘/site/app/storage’: No such file or directory

有什么想法吗?

【问题讨论】:

    标签: laravel amazon-web-services permissions amazon-elastic-beanstalk


    【解决方案1】:

    问题是我忽略了日志目录,所以它根本不在服务器上。不是服务器无法写入,而是它不存在。

    Elastic Beanstalk 创建的实例的默认权限为:

    文件664

    目录775

    它们由 Apache 用户部署和拥有。

    【讨论】:

    • 你忽略了日志目录是什么意思?我遇到了同样的问题,但在项目 .gitignore 中我没有忽略存储目录。它是否与每个文件夹中的所有 .gitignore 文件有关? (日志、会话等)
    • 我认为我忽略了主目录中 .gitignore_global 中的日志。看看那个。如果没有,请在日志目录中放置一个空的 .gitignore 文件,因为 Git 不会跟踪空目录。
    • 谢谢@Josh。我们正在使用 Jenkins 来推送我们的构建,结果发现它正在删除 .gitignore 文件(这些文件都在这些文件夹中),然后删除了这些文件夹,因为它们是空的。我在每个文件夹中添加了一些虚拟文件,它立即解决了文件夹消失的问题。
    【解决方案2】:

    对于其他有此问题的人...这会奏效:

    container_commands:
      01storage_permissions:
        command: "chmod -fR 755 /var/app/ondeck/app/storage"
    

    【讨论】:

    • 路径应该是/var/app/ondeck/storage
    猜你喜欢
    • 2020-11-10
    • 2014-12-30
    • 2013-04-28
    • 2016-03-08
    • 2019-07-16
    • 2013-08-13
    • 1970-01-01
    • 1970-01-01
    • 2017-01-17
    相关资源
    最近更新 更多