I have a laravel 7 application running on a server (Ubuntu 18.04 LTS, apache2 webserver). My problem is, that php artisan cache:clear
does return "Failed to clear cache. Make sure you have the appropriate permissions."
I tried the following approaches without success:
chmod -R 775 storage
php artisan config:cache
New created cache folders in "storage/framework/cache/data" are sometimes owned by user root, this seems to be the problem.
If I delete these folders manually it works till new root folders are created.
With ps -aux
I saw that the laravel process was running from user root. I changed this with sudo -u myusername
, but this didnt change the behaviour. I am starting the laravel application (php artisan serve
) within the rc.local script on server restart.
The current user "myusername" is in the group www-data.
You have to run webserver from the user that is belongs to the same usergroup with your current user. By default rc.local
call commands from root
user, which is not what you need.
Edit your rc.local
this way:
su user01 -c 'php /var/www/artisan serve'
Where user01
is your current user and /var/www/artisan
is full path to your artisan file. Also maybe you should specify full path to your php bin file, like /usr/bin/php
or else.
More details here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With