简体   繁体   中英

Laravel and AWS Elastic Beanstalk - File Permissions

I've created a Laravel app and deployed it to an EC2 instance using Elastic Beanstalk. Everything seems to work except that PHP can't write to the storage directory so I get this error:

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

This looks like a permissions problem to me, so I've tried using the instructions at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html to set the permissions.

I have one file 01permissions.config in the .ebextensions directory:

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

I get the following errors in server logs:

[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

Any ideas what's going on here?

The issue was that I had ignored the logs directory so it wasn't on the server at all. It's not that the server couldn't write to it, it's that it didn't exist.

The default permissions for an instance created by Elastic Beanstalk are:

File 664

Dir 775

They are deployed and owned by the Apache user.

For anyone else with this problem... this would have worked:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM