Laravel和AWS Elastic Beanstalk - 文件权限

时间:2014-11-22 16:17:27

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

我创建了一个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上的说明来设置权限。

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

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

有什么想法在这里发生了什么?

2 个答案:

答案 0 :(得分:1)

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

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

档案664

Dir 775

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

答案 1 :(得分:1)

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

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