3

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Good point, I would like my artisan commands to work fast since they are a core part of my product...but at least a user doesn't need to wait on them to finish.
Just as a heads up to you, I'm personally moving away from file storage cache to a Redis DB. Takes more RAM obviously, since its in-memory storage, but I like it a lot.
0

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

$ chmod --help

2 Comments

I've done this. The problem is that sub folders are created without these permissions when cache is added.
Probably pre-creating and chmoding them might help

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.