Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel storage/framework/sessions on EC2 gives failed to open stream

I use to have a working deployment system to amazon beanstalk with EC2 servers and recently I added some optimization post commmands to my scripts such as

composer dump-autoload
sudo php artisan optimize --force
sudo php artisan route:cache

Now on one of my API endpoints it's strange I get half of the data then at the end I have an error

file_put_contents(/var/app/ondeck/storage/framework/sessions/34325rfeq4324qfgr4): failed to open stream: No such file or directory

What's causing this and how do I fix this in the ec2 deployment setup?

EDIT

I just found out something! If on the server thats giving me the error I run this command below to clear the config cache my error dissapears. So how exactly do I fix this so that I can still run php artisan config:cache and not have it break?

php artisan config:clear
like image 871
user391986 Avatar asked Nov 29 '25 11:11

user391986


1 Answers

The reason why you're having this issue is because you're running artisan config:cache before the "release" - on /var/app/ondeck

if you run eb ssh, you'll see that your app is living inside /var/www

You need to run config:cache using a post deploy hook - however it seems that this isn't officially supported yet. Here's a workaround: http://junkheap.net/blog/2013/05/20/elastic-beanstalk-post-deployment-scripts/

like image 60
Jad Joubran Avatar answered Dec 01 '25 02:12

Jad Joubran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!