Sam
Sam

Reputation: 20486

Laravel artisan cache permission issues

I am using Laravel's file caching system (at least temporarily) to cache numerous smaller, mainly static objects from the database. However, if I use artisan to run some functions (which add/call from the cache) and then try to load a webpage, I get permission errors while trying to access the cache. Same error when done the other way around (view web page and then run artisan).

This is because the cache is owned by me when I run an artisan command, but is owned by apache when run through the webpage.

I have thought of 2 solutions. One, delete all the cache at the beginning and end of all artisan calls (not ideal, loses most of the performance boosts). Or, run all my artisan commands as the apache user (not convenient, and maybe not even possible).

Is there a way to modify the permissions automatically of Laravel's file caching? Or set artisan's caching to use the apache user maybe?

Upvotes: 3

Views: 1463

Answers (2)

John Veldboom
John Veldboom

Reputation: 2267

Not the most elegant solution, but I ended up just removing caching from my artisan commands. These were just background tasks that did not need the same speed boost as the front end does.

Upvotes: 1

Neo
Neo

Reputation: 886

You can try to chmod the storage folder to 0777. You can do this using your command line.

$ chmod --help

Upvotes: 0

Related Questions