1

The server sometimes encounter permission errors. When checked the cache directory the cache files are being written under different users and permissions. I guess the issue is causing because of that. Why Laravel is writing caches under different users and permission? How to change the user to www-data ?

enter image description here

I'm using (https://github.com/grosv/laravel-passwordless-login) for creating passwordless login and the caches are written by this package.

AH.
  • 741
  • 1
  • 12
  • 27
  • 1
    Are there any Laravel commands being run from CLI? – brombeer Jun 20 '22 at 06:20
  • @brombeer I've commands running from CLI which is schedule run. ```* * * * * cd /home/ubuntu/www && php artisan schedule:run >> /dev/null 2>&1``` – AH. Jun 20 '22 at 07:28

2 Answers2

1

I thought the problem occurs like you said "This is actually Laravel creating file under multiple users & permission"

Today I change the user to execute the command in crontab

* * * * * cd /home/ubuntu/www && sudo -Hu www-data php artisan schedule:run >> /dev/null 2>&1

That the cache data owner:group will be www-data:www-data.

It solve my problem that the same with you, I think it maybe an alternative solution to you.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Joe
  • 11
  • 3
0

run this command

first

sudo chown -R $USER:www-data storage 
sudo chown -R $USER:www-data bootstrap/cache

then

sudo chmod -R 775 storage 

sudo chmod -R 775 bootstrap/cache
Farhad
  • 191
  • 5
  • I already assigned permission like the above. This is actually Laravel creating file under multiple users & permission – AH. Jun 20 '22 at 07:29