2014-11-22 124 views
1

我创建了一个Laravel应用程序并使用Elastic Beanstalk将其部署到EC2实例。一切似乎除了PHP来工作,所以我得到这个错误不能写入storage目录:Laravel和AWS Elastic Beanstalk - 文件权限

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 

任何想法是怎么回事?

回答

1

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

由弹性魔豆创建的实例的默认权限是:

文件664

迪尔775

他们部署和Apache的用户拥有。

+0

你什么意思,你忽视了日志目录?我有同样的问题,但在项目中没有.gitignore我忽略存储目录。它是否与每个文件夹中的所有.gitignore文件有关? (日志,会话等) – 2015-03-26 18:38:01

+0

我想我在主目录中忽略了.gitignore_global中的日志。看看这个。如果没有,请在日志目录中放置一个空的.gitignore文件,因为Git不会跟踪空目录。 – Josh 2015-03-26 21:14:01

+1

谢谢@Josh。我们正在使用Jenkins来推动我们的构建,事实证明它正在删除.gitignore文件(这些文件夹都在这些文件夹中),然后删除文件夹,因为它们是空的。我为每个文件夹添加了一些虚拟文件,并立即修复了消失的文件夹问题。 – 2015-03-27 12:37:44

1

为别人这个问题...这会工作:

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